Skip to content

Instantly share code, notes, and snippets.

View nczz's full-sized avatar
🇹🇼
寫 code 不一定會幫你賺到錢,但會寫 code 能生活的有意思點。

一介資男 nczz

🇹🇼
寫 code 不一定會幫你賺到錢,但會寫 code 能生活的有意思點。
View GitHub Profile
@nczz
nczz / app.js
Created August 22, 2013 06:13 — forked from nulltask/app.js
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, socket = require('socket.io')
, RedisStore = socket.RedisStore
, cluster = require('cluster');
var io = require('socket.io-client');
var connection = process.env.LATENCY_CONNECTION || 100;
var host = process.env.LATENCY_HOST || 'localhost';
var options = {
port: process.env.LATENCY_PORT || 3000,
'force new connection': true
};
for (var i = 0; i < connection; i++) {
(function() {
@nczz
nczz / html5_readFile.html
Last active December 21, 2015 15:19
HTML5 Read File Example / HTML5 讀檔範例
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>File IO</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script>
$(function() {
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success! All the File APIs are supported.
} else {
var exec = require('child_process').exec;
var app = require('express.io')();
app.http().io();
function execCmd (argument) {
child = exec(argument,
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
<article id="post-49" class="post-49 post type-post status-publish format-standard hentry category-news">
<header class="entry-header">
<img width="239" height="261" src="http://undo.im/koikid/wp-content/uploads/2014/03/pic5.png" class="attachment-post-thumbnail wp-post-image" alt="pic5" />
<h1 class="entry-title">
<a href="http://undo.im/koikid/%e6%b8%ac%e8%a9%a6post/" rel="bookmark">
測試POST
</a>
</h1>
</header>
// The .config() part is the relevant part, 'SomeModule' is arbitrary name,
// but this config() call goes on your main ng-app="YourAppModule"
// The PHP $_POST expects data w/ a form content type, not a JSON payload
angular.module("YourAppModule", ["SomeModule"]).config(function($httpProvider) {
$httpProvider.defaults.headers.put['Content-Type'] =
'application/x-www-form-urlencoded';
$httpProvider.defaults.headers.post['Content-Type'] =
'application/x-www-form-urlencoded';
});
var serialize = function(obj, prefix) {
// http://stackoverflow.com/questions/1714786/querystring-encoding-of-a-javascript-object
var str = [];
for(var p in obj) {
var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
str.push(typeof v == "object" ? serialize(v, k) : encodeURIComponent(k) + "=" + encodeURIComponent(v));
}
return str.join("&");
}
@nczz
nczz / goodgood
Last active August 29, 2015 14:21
乖乖
.;###+;.
.;'''''''''''', :####++++++####; ,;;
;''''''''''''''''''''''` `###+++++++++++++++##, ,++++''+'
'''''''''''''''''
@nczz
nczz / mailchimp.sample.php
Created June 11, 2015 14:46
MailChimp PHP Curl Add member to list
<?php
$URL='http://us11.api.mailchimp.com/3.0/lists/LISTID/members';
$data = array("email_address"=>"xxX@sample.com","status"=>"subscribed","merge_fields"=>array("FNAME"=>"江","LNAME"=>"小屁","MMERGE3"=>"江小屁"));
$data_string = json_encode($data);
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$(document).ready(function() {
var slider = $('.bxslider').bxSlider({
pager: false,
controls: false,
touchEnabled:false
});
$('#go').click(function() {
slider.goToNextSlide();
});