Skip to content

Instantly share code, notes, and snippets.

View JoonHoSon's full-sized avatar

JoonHo Son JoonHoSon

  • Incheon, Republic of Korea
View GitHub Profile

Rust Error Handling Cheatsheet - Result handling functions

Introduction to Rust error handling

Rust error handling is nice but obligatory. Which makes it sometimes plenty of code.

Functions return values of type Result that is "enumeration". In Rust enumeration means complex value that has alternatives and that alternative is shown with a tag.

Result is defined as Ok or Err. The definition is generic, and both alternatives have

@JoonHoSon
JoonHoSon / iframe.js
Created October 29, 2024 06:55 — forked from PechenkiUA/iframe.js
Youtube iframe contentWindow.postMessage command
document.querySelector('iframe').contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
@JoonHoSon
JoonHoSon / pre-commit-cargo-fmt
Last active September 6, 2023 12:52 — forked from hryniuk/pre-commit-cargo-fmt
Git `pre-commit` hook that checks Rust code style with `cargo fmt`
#!/bin/bash
CARGO_HOME=/Users/joonho/.cargo
diff=$($CARGO_HOME/bin/cargo fmt -- --check)
result=$?
if [[ ${result} -ne 0 ]] ; then
cat <<\EOF
There are some code style issues, run `cargo fmt` first.
@JoonHoSon
JoonHoSon / README.md
Created October 13, 2020 01:36 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@JoonHoSon
JoonHoSon / UIDeviceHardware.h
Created February 18, 2019 05:39 — forked from Jaybles/UIDeviceHardware.h
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@JoonHoSon
JoonHoSon / git_gpt_tower.md
Created November 6, 2018 06:05 — forked from scisco/git_gpt_tower.md
Make git gpg work with Tower

source: https://aaronparecki.com/2016/07/29/10/git-tower

Configure your git client to always sign commits:

$ git config --global commit.gpgsign true

Try to sign a commit from the command line before trying it with Tower. Once you're able to successfully sign commits from the command line, you can set it up to work with Tower.

Add no-tty to your GPG configuration, to allow Tower to use it:

#!/bin/bash
#
# tomcat This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
@JoonHoSon
JoonHoSon / as_blueprint.py
Created July 3, 2018 15:00 — forked from mattupstate/as_blueprint.py
An `as_blueprint` method for Flask MethodView classes
from flask import Flask, Blueprint
from flask.views import MethodView
class ApiResource(MethodView):
endpoint = None
url_prefix = None
url_rules = {}
@classmethod
@JoonHoSon
JoonHoSon / build.gradle
Created July 1, 2018 12:44 — forked from dsdstudio/build.gradle
gradle javadoc 한글깨짐문제 해결
javadoc {
options.addStringOption("locale","ko_KR");
options.addStringOption("encoding","UTF-8");
options.addStringOption("charset","UTF-8");
options.addStringOption("docencoding","UTF-8");
}
@JoonHoSon
JoonHoSon / Converting libraries to Ember CLI addons.md
Created April 19, 2017 01:57 — forked from kristianmandrup/Converting libraries to Ember CLI addons.md
Guide to Developing Addons and Blueprints for Ember CLI

Converting libraries to Ember CLI addons

In this guide we will cover two main cases:

  • Ember specific library
  • vendor library

Ember library

The Ember library will assume that Ember has already ben loaded (higher in the loading order) and thus will assume it has access to the Ember API.