Skip to content

Instantly share code, notes, and snippets.

@romeoh
romeoh / detect.js
Created January 29, 2015 00:33
Detect Library
/**
description: Content script that runs after DOM loaded to look for the Library
Detector meta element. If found, notifies the extension of the
script information
**/
function wait() {
var meta = document.getElementById('d41d8cd98f00b204e9800998ecf8427e_lib_detect');
if (meta) {
chrome.extension.sendMessage(meta.content);
angular.module('app', [])
.controller('apps', function($scope, $http){
var url = 'https://api.mongolab.com/api/1/databases/cheat/collections/projects?apiKey=<apiKey>'
$http
.get(url)
.success(function(data){
console.log(data)
})
})
@romeoh
romeoh / gist:88c5e3b424566a3c62ef
Created October 17, 2014 03:33
ios url scheme
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>KFT</title>
<link rel="stylesheet" type="text/css" href="./css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="./css/common.css">
window.location.href='storylink://profile?id=romeoh&ref=hetory'
@romeoh
romeoh / gist:6153383
Created August 5, 2013 03:50
uri encoder
encodeURI() / decodeURI()
최소한의 문자만 인코딩합니다.
; / ? : @ & = + $ , - _ . ! ~ * ' ( ) #
이런 문자는 인코딩하지 않습니다.
http:// ... 등은 그대로 나옵니다.
encodeURIComponent() / decodeURIComponent()
알파벳과 숫자 Alphanumeric Characters 외의, 대부분의 문자를 모두 인코딩합니다.
http:// ... 가 http%3A%2F%2F 로 됩니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://opengraphprotocol.org/schema/"
xmlns:fb="http://www.facebook.com/2008/fbml"
lang="ko"
xml:lang="ko" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function getShortUrl(url) {
var tdata = '{"longUrl": "' + url + '"}';
$.support.cors = true;
$.ajax({
url: "https://www.googleapis.com/urlshortener/v1/url",
type: "POST",
dataType: "json",
data: tdata,
@romeoh
romeoh / gist:6110342
Created July 30, 2013 04:58
function map
<script type='text/javascript'>
var FuncPool = new function () {
this.buffer = new Object();
// create set key
this.createSetKey = function() {
var sKey = '';
while (true) {
/* map */
Mp.Map = function() {
this.array = [];
}
Mp.Map.prototype = {
put: function(key, value){
var index = this.getIndex(key);
if (index > -1) {
this.array[index] = {key: key, value: value};
} else {
@romeoh
romeoh / gist:5640821
Created May 24, 2013 02:00
GAE 폼전송.
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write("""
<html>