Skip to content

Instantly share code, notes, and snippets.

View peerax's full-sized avatar

peerathai puapan peerax

View GitHub Profile
@peerax
peerax / conCSVtoSQlite.py
Created August 26, 2014 07:35
python import txt,csv to sqlite
import csv, sqlite3
conn = sqlite3.connect("converting2.sqlite")
curs = conn.cursor()
curs.execute("CREATE TABLE document (col1 TEXT, col2 TEXT, col3 TEXT, col4 TEXT,col5 TEXT);")
reader = csv.reader(open('Calendar.txt', 'rU'), delimiter=' ')
for row in reader:
to_db = [unicode(row[0], "utf8"), unicode(row[1], "utf8"), unicode(row[2], "utf8"), unicode(row[3], "utf8"), unicode(row[4], "utf8")]
curs.execute("INSERT INTO document VALUES (?, ?, ?,?,?);", to_db)
conn.commit()
@peerax
peerax / dht.py
Created August 27, 2014 09:56
DHT11,22,2302 in python from https://github.com/adafruit
import sys
import dhtreader
DHT11 = 11
DHT22 = 22
AM2302 = 22
dhtreader.init()
@peerax
peerax / my.cnf
Created August 28, 2014 03:30
mySQL config file for ram 8GB
# my.cnf for TAKIS Server
# BEGIN CONFIG INFO
# DESCR: 8 GB RAM, InnoDB only, ACID, few connections, heavy queries
# TYPE: SYSTEM
# END CONFIG INFO
[client]
port = 7000
socket = /var/lib/mysql/mysql.sock
@peerax
peerax / NSUrlSession POST
Created August 28, 2014 09:03
NSUrlsession use POST
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
NSMutableURLRequest *request = [NSMutableURLRequest
requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%@/getAllUser",[GlobalVar serverIp],[GlobalVar serverPort]]]];
NSDictionary *requestData = [[NSDictionary alloc] initWithObjectsAndKeys:
[defu objectForKey:@"ComId"], @"id",
nil];
NSError *error;
NSData *postData = [NSJSONSerialization dataWithJSONObject:requestData options:0 error:&error];
//Register Notification ในviewDidLoad
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(ชื่อฟังค์ชั่น) name:@"ชื่อโนติ" object:nil];
//Call Notification main thread
[[NSNotificationCenter defaultCenter]postNotificationName:@"ชื่อโนติ" object:self];
@peerax
peerax / gist:b2d191f1be5e20fd875a
Created September 9, 2014 15:21
arduino gsm gprs code
http://stackoverflow.com/questions/8500698/use-arduino-gsm-gprs-shield-to-send-data-to-my-web-service
@peerax
peerax / ios sqlite
Created December 15, 2014 15:33
SQlite ios Set get version
PRAGMA user_version;//Get
PRAGMA user_version = 2; //Set
//
// AppDelegate.swift
// pushtest
//
// Created by sawapi on 2014/06/08.
// Copyright (c) 2014年 sawapi. All rights reserved.
//
// iOS8用
import UIKit
@peerax
peerax / APNSTest.rb
Last active August 29, 2015 14:13 — forked from vzqwer/APNSTest.rb
# Install APNS gem:
# sudo gem install APNS
require 'APNS'
# gateway.sandbox.push.apple.com is default
# APNS.host = 'gateway.push.apple.com' # Production
APNS.host = 'gateway.sandbox.push.apple.com' # Development
# this is also the default. Shouldn't ever have to set this, but just in case Apple goes crazy, you can.
APNS.port = 2195
@peerax
peerax / add
Created January 26, 2015 08:54
Add UIBarbutton
UIBarButtonItem *btn =[[UIBarButtonItem alloc] initWithTitle:@"Check out" style:UIBarButtonItemStyleBordered target:self action:@selector(Checkout)];
self.navigationItem.rightBarButtonItem = btn;