Skip to content

Instantly share code, notes, and snippets.

@goliatone
goliatone / NodeJS - Http Post.js
Last active August 28, 2015 11:48 — forked from wuchengwei/NodeJS - Http Post.js
NodeJS - Http Post
//doHttpPost('localhost', 8000, '/TestPost', 'string' , 'TestTestTestTest', false);
//doHttpPost('localhost', 8000, '/TestPost', 'file' , '/Users/chengwei/Downloads/grid1.png', true);
function doHttpPost(_host, _port, _path, name, value, isFile, fileEncoding) {
var http = require('http'),
fs = require('fs'),
path = require('path'),
boundary = Math.random(),
postData, postOptions, postRequest;
<!-- Drop this in ~/Library/Preferences/PyCharm20/tools -->
<!-- make sure you set the path to flake8 executable for your machine in the COMMAND option -->
<?xml version="1.0" encoding="UTF-8"?>
<toolSet name="Flake8">
<tool name="Flake8 File" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="false" disabled="false" useConsole="true" synchronizeAfterRun="true">
<exec>
<option name="COMMAND" value="/usr/local/bin/flake8" />
<option name="PARAMETERS" value="--max-line-length=120 --ignore=E301,E302,E261,E262,W404 $FileDir$/$FileName$" />
<option name="WORKING_DIRECTORY" value="$FileDir$" />
defmodule Test1 do
def upto(n) when n > 0 do
1..n |> Enum.map(&fizzbuzz/1)
end
defp fizzbuzz(n) when rem(n, 3) == 0 and rem(n, 5) == 0, do: "FizzBuzz"
defp fizzbuzz(n) when rem(n, 3) == 0, do: "Fizz"
defp fizzbuzz(n) when rem(n, 5) == 0, do: "Buzz"
defp fizzbuzz(n), do: n
@goliatone
goliatone / extend.js
Created February 16, 2014 04:13
Deep extend method
var extend = function extend(target) {
var sources = [].slice.call(arguments, 1);
sources.forEach(function (source) {
for (var property in source) {
if(source[property] && source[property].constructor &&
source[property].constructor === Object){
target[property] = target[property] || {};
target[property] = extend(target[property], source[property]);
} else target[property] = source[property];
}
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};
@goliatone
goliatone / transition_events.js
Created March 11, 2014 16:02
cross browser transition events
var _getTransitionEvent = function(){
if(this._transition) return this._transition;
var transitions = {
'transition':'transitionend',
'OTransition':'oTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
};
return _transition = (function(){
var xmpp = require('node-xmpp'),
secret = require('./secret'),
util = require('util');
var creds = {
jid: 'bengoering@gmail.com',
password: secret.pw, //string
};
var GChat = function(creds) {
var _hasProp = {}.hasOwnProperty,
_inherit = function (child, parent) {
for (var key in parent) {
if (_hasProp.call(parent, key)) child[key] = parent[key];
}
if(typeof child === 'string') child = self;
function ctor() {
this.constructor = child;
@goliatone
goliatone / git_branch_by_date.sh
Created March 18, 2014 19:40
git, order branches by commit date
git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(authorname) %(refname:short)'
#2014-03-18 goliatone 251_how_a_bill_becomes_a_law_html_css
#2014-03-18 goliatone 292_what_you_can_do_timestamping
#2014-03-18 goliatone 138_WYCD_data_viz