Skip to content

Instantly share code, notes, and snippets.

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

一介資男 nczz

🇹🇼
寫 code 不一定會幫你賺到錢,但會寫 code 能生活的有意思點。
View GitHub Profile
<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();
});
jQuery('a').click(function(e){
var url = jQuery(this).attr('href');
if (!/^([javascript]|[mailto])/.test(url)){
e.preventDefault();
location=url+location.search+location.hash;
}
});
@nczz
nczz / WriteForLittlePig.js
Created September 11, 2015 07:38
WriteForLittlePig
//1~4
for (var i=1; i<5; ++i){
$('#menu_'+i).click(function(){
$('#tab_'+$(this).attr('id').split('_')[1]).trigger('click');
});
}
@nczz
nczz / Power of Thor.js
Created October 11, 2015 13:21
codingame.com -> Power of Thor JavaScript solution
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
* ---
* Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
**/
var inputs = readline().split(' ');
var lightX = parseInt(inputs[0]); // the X position of the light of power
var lightY = parseInt(inputs[1]); // the Y position of the light of power
#include <stdio.h>
#include <sys/types.h>
#include <ifaddrs.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
int main (int argc, const char * argv[]) {
struct ifaddrs * ifAddrStruct=NULL;
struct ifaddrs * ifa=NULL;