Skip to content

Instantly share code, notes, and snippets.

View 1ambda's full-sized avatar
🦁
in the jungle

Kun 1ambda

🦁
in the jungle
View GitHub Profile
@1ambda
1ambda / gist:757eb50592240e4ee1fd
Created May 7, 2015 14:25
Scala Cancellable Future Implementation
package lecture
import org.junit.runner.RunWith
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.junit.JUnitRunner
import org.scalatest._
import scala.concurrent.{Await, Future, Promise}
import scala.util.Success
import scala.async.Async._
@1ambda
1ambda / gist:16f5ae62a48f399d42ac
Last active August 29, 2015 14:20
Weather Information Using Rx Javascript
"use strict";
var Rx = require('rx');
var axios = require('axios');
var city = 'seoul';
var api = 'http://api.openweathermap.org/data/2.5/weather?mode=json&units=metric&q=' + city;
var p = axios.get(api); /* promise */
var o = Rx.Observable
@1ambda
1ambda / Time.js
Created June 2, 2015 17:47
Time.js
// Syrup
this.formatDate = function(num){
var fom = "";
var iNum;
if(!isNaN(num)){
iNum = Number(num);
if(iNum < 10) { fom = "0" + iNum; }
else { fom = "" + iNum; }
@1ambda
1ambda / Track.js
Created June 2, 2015 17:54
Track.js
<script type="text/javascript">
var isDev = true;
var token = "token";
var rakeJSVersion = "1.3";
(function(e,b){var versionConnector=rakeJSVersion==""?"":"-"; if(!b.__SV){var a,f,i,g;window.mixpanel=b;a=e.createElement("script");a.type="text/javascript";a.async=!0;if(isDev){a.src='https://pg.rake.skplanet.com:8443/log/resources/js/rake-skp.test'+versionConnector+rakeJSVersion+'.min.js';}else{a.src='https://rake.skplanet.com:8443/log/resources/js/rake-skp'+versionConnector+rakeJSVersion+'.min.js';};f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f);b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview tr
@1ambda
1ambda / experiment.js
Created June 8, 2015 02:28
Experiment.js
rake_lat.init({
log_version : rakeJSVersion,
current_page : "/detail/brand_latency",
latency_flag : "Y",
latency_module_cnt : 7,
latency_time_stamp: rake_lat.getLatencyId()
});
// rake_lat.sendRakeData({latency_module_order : "0"});
setTimeout(function() {
@1ambda
1ambda / rake-1.3.js
Created June 8, 2015 02:49
rake-1.3
/*
*
* rake-javascript-skp
* ===================
*
* ## Javascript Library for web application tracking ##
* ### based on Mixpanel JS Library ###
*
* Mixpanel JS Library v2.2.0
*
@1ambda
1ambda / usage.js
Last active August 29, 2015 14:25
var isDev = true;
var token = "your rake token";
var rakeJSVersion = 1.5;
(function(e,b){var versionConnector=rakeJSVersion==""?"":"-"; if(!b.__SV){var a,f,i,g;window.mixpanel=b;a=e.createElement("script");a.type="text/javascript";a.async=!0;if(isDev){a.src='https://pg.rake.skplanet.com:8443/log/resources/js/rake-skp.test'+versionConnector+rakeJSVersion+'.min.js';}else{a.src='https://rake.skplanet.com:8443/log/resources/js/rake-skp'+versionConnector+rakeJSVersion+'.min.js';};f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f);b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable collect flush track track_pageview track_links tra
@1ambda
1ambda / send_mail.py
Last active August 29, 2015 14:26 — forked from vjo/send_mail.py
[Python] Send email with embedded image and application attachment
#! /usr/bin/python
import smtplib
from optparse import OptionParser
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
@1ambda
1ambda / Example.scala
Created September 25, 2015 08:48 — forked from noelwelsh/Example.scala
Robust Error Handling in Scala
import scalaz.\/
import scalaz.syntax.either._
object Example2 {
// This example simulates error handling for a simple three tier web application
//
// The tiers are:
// - the HTTP service
// - a user authentication layer
// - a database layer
@1ambda
1ambda / HttpRequestSpec.scala
Created October 9, 2015 02:26
Monocle HttpRequest example
import org.scalatest._
import monocle._, Monocle._, monocle.macros._
/* ref - http://www.slideshare.net/JulienTruffaut/beyond-scala-lens */
class HttpRequestSpec extends WordSpec with Matchers {
import HttpRequestSpec._
val r1 = HttpRequest(
GET,
URI("localhost", 8080, "/ping", Map("hop" -> "5")),