Skip to content

Instantly share code, notes, and snippets.

View peerax's full-sized avatar

peerathai puapan peerax

View GitHub Profile
@peerax
peerax / HTTPpost.java
Created January 30, 2015 06:55
Android Request HTTP class
import android.os.Handler;
import android.os.Message;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
@peerax
peerax / animation.m
Created January 30, 2015 09:57
ios custom transition
- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
UIViewController *destinationViewController = self.destinationViewController;
// Add the destination view as a subview, temporarily
[sourceViewController.view addSubview:destinationViewController.view];
// Transformation start scale
destinationViewController.view.transform = CGAffineTransformMakeScale(0.05, 0.05);
class ViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 2
}
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://testcURL.com/?item1=value&item2=value2',
CURLOPT_USERAGENT => 'Codular Sample cURL Request'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
<html>
<head>
<script type="text/javascript">
function validateMyForm()
{
if(1 == 6)
{
alert("validation failed false");
returnToPreviousPage();
return false;
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="httpreq.js"></script>
<script>
function chkTxt(){
var str = $("#txt").val();
var b = str.replace(/[^a-z0-9_-]/gi,'');
$("#txt").val(b);
@peerax
peerax / index.html
Created April 4, 2015 09:27
nodejs+express+ejs .html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<% include ../partials/head %>
<title></title>
</head>
<body>
<%= title.date %>
</body>
@peerax
peerax / kmtoday.js
Created April 27, 2015 08:34
request today in js
// Today.init(); เรียกวันนี้
// Today.prevDate(2); เรียกอีกสองวันข้างหน้า
var Today = function(){
return{
init: function () {
var today = new Date();
return getDBformat(today);
},
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
if application.respondsToSelector("registerUserNotificationSettings:") {
let types:UIUserNotificationType = (.Alert | .Badge | .Sound)
let settings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
@peerax
peerax / Yii_Ar_to_json.php
Created February 20, 2017 09:16
Yii Active record to json
$models=Bla::model()->findAll();
$data=array_map(create_function('$m','return $m->getAttributes(array(\'id\',\'name\'));'),$models);
echo json_encode($data);