Skip to content

Instantly share code, notes, and snippets.

@kmtr
kmtr / gist:5567921
Created May 13, 2013 12:20
remove .DS_Store
find . -name ".DS_Store" -print -exec rm {} \;

load and compile CoffeeScript

fs = require 'fs'
vm = require 'vm'
CoffeeScript = require 'coffee-script'
  
filePath = 'loader.litcoffee'
coffeeSource = fs.readFileSync filePath, {encoding: 'utf8'}
jsSource = CoffeeScript.compile coffeeSource, {literate: true}              
console.log jsSource
@kmtr
kmtr / hash.go
Created August 12, 2013 20:33
golang hash
package main
import (
"crypto/md5"
"crypto/sha512"
"fmt"
)
func main() {
hash := md5.New()
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github</groupId>
<artifactId>kmtr</artifactId>
<name>test</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
(defproject beaconlog "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [
[org.clojure/clojure "1.5.1"]
[compojure "1.1.6"]
[de.ubercode.clostache/clostache "1.3.1"]
[markdown-clj "0.9.35"]
@kmtr
kmtr / gist:7929809
Created December 12, 2013 15:31
insert a file object to blob
(ns beaconlog.db
(:use clojure.core)
(:require [clojure.java.jdbc :as j]))
(defn insert-file [file]
(j/db-transaction [db db-spec]
(let [buffer (byte-array (.length file))]
(j/insert! db :blob_table {:binary buffer}))))
<?php
/**
* php.ini
* phar.readonly=0
*
*
* /path/to/dir
* buildphar.php
* /src
package main
import (
"fmt"
"reflect"
"unsafe"
)
func Put(p unsafe.Pointer, key interface{}, value interface{}) {
mapType := reflect.MapOf(reflect.TypeOf(key), reflect.TypeOf(value))
@kmtr
kmtr / .vimrc
Last active March 6, 2016 00:13
scriptencoding utf-8
if &compatible
set nocompatible
endif
"$ mkdir -p ~/.vim/dein/repos/github.com/Shougo/dein.vim
"$ clone https://github.com/Shougo/dein.vim.git ~/.vim/dein/repos/github.com/Shougo/dein.vim
set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim
call dein#begin(expand('~/.vim/dein'))
@kmtr
kmtr / server.js
Last active August 29, 2015 14:15
var server = null;
var port = 3000;
var mbedUrl = 'http://192.168.100.44';
function redirect(req, res, oncomplete){
console.log(req);
var path = req._path + '?' + req._queryString;
var req = new XMLHttpRequest();
req.open('GET', mbedUrl + path, true);
try {