Skip to content

Instantly share code, notes, and snippets.

View veer66's full-sized avatar

Vee Satayamas veer66

View GitHub Profile
x.map do |y|
puts "^^ #{y} ^^"
end
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Selecting text via API</title>
</head>
<body>
<div><span id="s1">ABCDEFGHI</span><span id="s2">12345</span></div>
<script>
var span = document.getElementById("s1");
@veer66
veer66 / gist:5206903
Last active December 15, 2015 05:09
Loop + queries + Q
var mysql = require('mysql');
var Q = require("q");
function createConnection() {
var conn = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'password',
database : 't2'
});
@veer66
veer66 / gist:5461215
Created April 25, 2013 16:43
Haskell มันไม่มี substr ใน standard library จริงหรือ เกรงว่าผมจะหาไม่เจอเอง แต่โปรแกรมนี้ทำงานถูกก็ใช้การได้แล้ว
substr :: [Char] -> Int -> Int -> [Char]
substr str start end =
let length' = end - start
in (take length' (drop start str))
main = do
x <- readFile "u8.txt"
putStrLn (substr x 3 8)
'use strict';
describe('StreeCorrCreator', function() {
var streeCorrCreator;
beforeEach(function() {
module('annotedw');
inject(function($injector) {
streeCorrCreator = $injector.get('StreeCorrCreator');
});
@veer66
veer66 / gaia_built
Created July 3, 2013 09:07
I plug Keon (nighly built 20130703) with Macbook Pro. Remote debug is already enable. But I cannot install gaia from github. I got following messages.
$ B2G_SYSTEM_APPS=1 make install-gaia
test -d profile || mkdir -p profile
run-js-command applications-data
Looking for packaged app: /Users/vee/Develop/gaia/external-apps/marketplace.firefox.com/update.webapp
run-js-command preferences
make[1]: Nothing to be done for `concatenated_scripts'.
make[1]: Nothing to be done for `concatenated_scripts'.
Finished: bootstrapping test proxies/sandboxes
Finished: test ui config file: ./test_apps/test-agent/config.json
require 'json'
require 'pp'
PP.pp JSON.parse($stdin.read)
@veer66
veer66 / app.js
Last active May 31, 2016 09:29
Incomplete user authentication code using pbkdf2, node.js and Q
var express = require('express');
var app = express();
var nconf = require('nconf');
var Q = require("q");
var crypto = require('crypto');
app.use(express.bodyParser());
app.post("/user/auth", function(req, res) {
res.set('Content-Type', 'application/json');
authUser(req.body.username, req.body.password).then(function(auth_result) {
@veer66
veer66 / display_png_from_gridfs.js
Created July 23, 2013 11:56
Retrieve image from GridFS
var express = require('express');
var app = express();
var Db = require('mongodb').Db,
MongoClient = require('mongodb').MongoClient,
ObjectID = require('mongodb').ObjectID,
GridStore = require('mongodb').GridStore;
app.get("/myimage.png", function(req, res) {
MongoClient.connect("mongodb://localhost:27017/mydb", function(err, db_) {
@veer66
veer66 / thaistring.go
Created August 20, 2013 12:29
อันนี้ได้ 6 2 นะ รู้สึกว่ามันดูยุ่ง ๆ ยาวเกินสำหรับคนที่ยุ่งกับพวกนี้เยอะ ๆ
package main;
import (
"fmt"
"unicode/utf8"
)
func main() {
s := "กา"
fmt.Println(len(s), utf8.RuneCountInString("กา"))