Skip to content

Instantly share code, notes, and snippets.

View katopz's full-sized avatar
🦀
Rust me if you can

Todsaporn Banjerdkit katopz

🦀
Rust me if you can
View GitHub Profile
@katopz
katopz / firebase_bridge.js
Last active August 29, 2015 14:28
Firebase via Meteor
// You have 3 choices
// 1st : npm way, you can use any npm after this (yeah!)
// Refer to : http://stackoverflow.com/questions/10165978/how-do-we-or-can-we-use-node-modules-via-npm-with-meteor
// $ meteor add meteorhacks:npm
// 2nd : mrt way
// $ meteor add mrt:firebase
// 3rd : diy way
// refer to : https://gist.github.com/kenyee/6307258
@katopz
katopz / firebase_bridge.js
Last active August 27, 2015 16:14
firebase_bridge.js for medium
var Firebase = Meteor.npmRequire("firebase");
var firebase = new Firebase('https://radiant-inferno-foo.firebaseio.com/');
firebase.on('child_added', willLog);
firebase.on('child_changed', willLog);
firebase.on('child_removed', willLog);
function willLog(snapshot) {
console.log(snapshot.key() + " : " + EJSON.stringify(snapshot.val()));
}
@katopz
katopz / firebase_authen.js
Last active September 7, 2015 05:45
Async call to authen Firebase via Meteor
// https://github.com/firebase/firebase-token-generator-node
Meteor.methods({
enterChat: function (userId) {
if (!userId) {
throw new Meteor.Error("not-logged-in",
"Must be logged in to enter chat.");
}
Meteor.methods({
getFirebaseToken: function (userId) {
if (!userId) {
throw new Meteor.Error("not-logged-in",
"Must be logged in to enter chat.");
}
var FirebaseTokenGenerator = Meteor.npmRequire("firebase-token-generator");
var tokenGenerator = new FirebaseTokenGenerator(YOUR_FIREBASE_SECRET);
@katopz
katopz / hello-mongodb.js
Created September 10, 2015 11:58
Hello world MongoDB via Meteor + Aggregate
// ref : https://github.com/meteorhacks/meteor-aggregate
Meteor.startup(function () {
// C : insert
console.log("## insert");
// insert list
var list_id = Lists.insert({
name: "foo",
incompleteCount: 1,
@katopz
katopz / cleanz.sh
Last active September 22, 2015 14:59
Clean Mac junk file in zip
zip -d foo.zip __MACOSX/\*
zip -d foo.zip \*/.DS_Store
Shader "Transparent/Cutout/DiffuseBack" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
Cull front
@katopz
katopz / MiniServer.cs
Last active December 23, 2015 07:30
POC C# TCP capture for .NET 4.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Diagnostics;
@katopz
katopz / MiniServer2.cs
Created December 23, 2015 07:30
POC : HttpListener
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Diagnostics;
@katopz
katopz / crazy_timezone.swift
Created January 18, 2016 16:30
Crazy Timezone
import Foundation
// 2016 eh?
var dateString = "Fri Jan 01 00:00:00 +1100 2016"
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "E MMM dd HH:mm:ss Z yyyy"
let calendar = NSCalendar.currentCalendar()
let components = calendar.components([.Day , .Month , .Year], fromDate: dateFormatter.dateFromString(dateString)!)