Skip to content

Instantly share code, notes, and snippets.

@tyfkda
tyfkda / encconv.rb
Created February 4, 2016 00:04
Convert string encoding
# Convert string encoding
# options:
# -e [encoding] Target encoding (default: utf-8)
require 'kconv'
require 'optparse'
def convert_encoding(lines, to)
encoding = Kconv.guess(lines.join)
// ex. Dictionary<string, string> dic;
foreach (KeyValuePair<string, string> pair in dic) {
Debug.Log(pair.Key + ": " + pair.Value);
}
@tyfkda
tyfkda / push-gcm.sh
Last active November 20, 2020 01:40
Google Cloud Messagingでプッシュ通知を送る ref: http://qiita.com/tyfkda/items/e880f1e7f4fb78e45322
curl --header 'Authorization: key=<APIキー>' \
--header Content-Type:"application/json" \
https://android.googleapis.com/gcm/send \
-d '{"registration_ids":["<端末の登録ID>"],"data":{"message":"Hello", "url": "http://www.example.com/"}}'
@tyfkda
tyfkda / RequestParseCloudFunction.cs
Last active November 20, 2020 01:42
C#からParse.comのCloudFunctionを呼び出して結果を受け取る ref: http://qiita.com/tyfkda/items/be2858031203921bb505
using Parse;
...
public void RequestFoobars(List<string> foobarIds) {
Dictionary<string, object> data = new Dictionary<string, object>();
data.Add("foobarIds", foobarIds);
ParseCloud.CallFunctionAsync<List<object>>("getFoobars", data).ContinueWith(t => {
if (t.IsFaulted || t.IsCanceled || !t.IsCompleted || t.Result == null) {
Debug.Log(t.Exception.GetBaseException().Message);
@tyfkda
tyfkda / mc68000-mnemonic.txt
Created March 5, 2015 23:20
MC68000 mnemonic
This file has been truncated, but you can view the full file.
0000 0123 ori.b #$23, D0
0001 0123 ori.b #$23, D1
0002 0123 ori.b #$23, D2
0003 0123 ori.b #$23, D3
0004 0123 ori.b #$23, D4
0005 0123 ori.b #$23, D5
0006 0123 ori.b #$23, D6
0007 0123 ori.b #$23, D7
0010 0123 ori.b #$23, (A0)
0011 0123 ori.b #$23, (A1)
@tyfkda
tyfkda / add-html-class.js
Created February 24, 2015 06:15
Add/remove class name to HTML element
// See. http://stackoverflow.com/a/22224493
// See also. http://caniuse.com/#feat=classlist
elem.classList.add('foobar');
elem.classList.remove('foobar')
elem.classList.contains('foobar')
@tyfkda
tyfkda / convert-c-to-nsstring.m
Created February 23, 2015 00:27
Convert C-string to NSString
NSString *nsstr = [NSString stringWithUTF8String:cstr];
@tyfkda
tyfkda / string-to-number.js
Created February 18, 2015 01:54
Convert string to number in JavaScript
// Int string -> Number
parseInt('123.456') // => 123
// Float string -> Number
parseFloat('123.456') // => 123.456
// Any
Number('123.456') // => 123.456
// Hex string -> Number
@tyfkda
tyfkda / formatted_nsstring.m
Created February 11, 2015 01:11
Create NSString with format
NSString *formatted = [NSString stringWithFormat: @"Hello, %@!", @"World"];
@tyfkda
tyfkda / use_json.js
Created February 11, 2015 01:11
JSON on JS
(function() {
var json = {a: 1, b: 2};
// Encode.
var str = JSON.stringify(json);
// Decode.
var decoded = JSON.parse(str);
})();