This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from glob import iglob | |
import pandas as pd | |
files = sorted(iglob('*.csv')) | |
frames = [ pd.read_csv(f) for f in files ] | |
result = pd.concat(frames) | |
final_csv = result.to_csv('./final.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$records = Import-Csv BadResults.csv | |
foreach($record in $records){ | |
$xml = new-object System.Xml.XmlDocument | |
$fraudScore = $record.FraudScoreDetails | |
$xml.LoadXml($fraudScore) | |
foreach ($i in $xml.response.rule){ | |
#Write-Output $i.criteriaEvaluated | |
#Write-Output $i.evaluationResult | |
$record | Add-Member NoteProperty $i.criteriaEvaluated $i.evaluationResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF | |
appify v3.0.1 for Mac OS X - http://mths.be/appify | |
Creates the simplest possible Mac app from a shell script. | |
Appify takes a shell script as its first argument: | |
`basename "$0"` my-script.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <node.h> | |
#include <string.h> | |
#include <v8.h> | |
using namespace v8; | |
unsigned long long count = 0; | |
// native blocking/compute intensive function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /usr/local | |
$ git checkout b64d9b9c431642a7dd8d85c8de5a530f2c79d924 Library/Formula/node.rb | |
$ brew unlink node | |
$ brew install node | |
$ npm install -g npm@latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# nodereinstall | |
# credit: http://stackoverflow.com/a/11178106/2083544 | |
# | |
# UPDATE: I've converted this gist to a repo: | |
# https://github.com/brock/node-reinstall | |
# | |
# get sudo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pre-render d3 charts at server side | |
var d3 = require('d3') | |
, jsdom = require('jsdom') | |
, fs = require('fs') | |
, htmlStub = '<html><head></head><body><div id="dataviz-container"></div><script src="js/d3.v3.min.js"></script></body></html>' | |
jsdom.env({ | |
features : { QuerySelector : true } | |
, html : htmlStub | |
, done : function(errors, window) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pre-render d3 force-directed graph at server side | |
// Call node pre_render_d3_graph.js to generate d3_graph.html | |
// Original idea and framework borrowed from https://gist.github.com/mef/7044786 | |
var d3 = require('d3') | |
, jsdom = require('jsdom') | |
, fs = require('fs') | |
, htmlStub = '<html><head> \ | |
<style>.node { stroke: #fff; fill: #ccc; stroke-width: 1.5px; } \ | |
.link { stroke: #333; stroke-opacity: .5; stroke-width: 1.5px; }</style> \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//... | |
protected function _setEnvironment($config) | |
{ | |
$env = new \stdClass(); | |
if (array_key_exists('ENV', $_SERVER) && isset($_SERVER['ENV'])) { | |
$env->name = $_SERVER['ENV']; | |
} else { | |
$env->host = $_SERVER['HTTP_HOST']; | |
foreach ($config['domains'] as $k => $v) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//... | |
foreach ($config->databases as $db => $cred) { | |
$this->di->set($db, function () use ($cred) { | |
$adaptor = "\\Phalcon\\Db\\Adapter\\Pdo\\{$cred->adapter}"; | |
return new $adaptor([ | |
'host' => $cred->host, | |
'username' => $cred->username, | |
'password' => $cred->password, | |
'dbname' => $cred->dbname |