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
var fs = require('fs'); | |
fs.readFile('testing.txt', {encoding:'utf8'}, function (err, data) { | |
if (err) throw err; | |
console.log('orig:\n' + data); | |
console.log('\n\n\nafter JSON.stringify:\n' + JSON.stringify(data)); | |
console.log('\n\n\nafter JSON.stringify escapeSpecialChars() :\n' + JSON.stringify(data).escapeSpecialChars()); | |
}); | |
String.prototype.escapeSpecialChars = function() { | |
return this.replace(/\\n/g, "\\n").replace(/\\'/g, "\\'").replace(/\\"/g, '\\"').replace(/\\&/g, "\\&").replace(/\\r/g, "\\r").replace(/\\t/g, "\\t").replace(/\\b/g, "\\b").replace(/\\f/g, "\\f"); |
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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://npmjs.org/install.sh | 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
// This module loads a config file in the current working directory matching the NODE_ENV variable. | |
// I.e. either './development.js' or './production.js' based on the process.env.NODE_ENV variable. | |
// If not set, it defaults to './development.js'. | |
// Can load custom environment files as well, as long as the NODE_ENV variable matches | |
// a file in the current directory. E.g. './staging.js' | |
// Usage: calling code can just require this module, e.g. "var config = require('./config')" | |
// assuming this file is named "index.js" and lives in a subdirectory named "config" of the app root. | |
var config | |
, config_file = './' + (process.env.NODE_ENV ? process.env.NODE_ENV : 'development') + '.js'; |
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
%w(pathname json openssl net/http digest/sha1 zip).each { |lib| require lib } | |
module Passbook | |
def self.wwdr_certificate | |
OpenSSL::X509::Certificate.new <<-EOF.gsub /^\s+/, "" | |
-----BEGIN CERTIFICATE----- | |
MIIEIzCCAwugAwIBAgIBGTANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQGEwJVUzET | |
MBEGA1UEChMKQXBwbGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlv | |
biBBdXRob3JpdHkxFjAUBgNVBAMTDUFwcGxlIFJvb3QgQ0EwHhcNMDgwMjE0MTg1 | |
NjM1WhcNMTYwMjE0MTg1NjM1WjCBljELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFw |
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
#!/usr/bin/python | |
# | |
# K-means clustering using Lloyd's algorithm in pure Python. | |
# Written by Lars Buitinck. This code is in the public domain. | |
# | |
# The main program runs the clustering algorithm on a bunch of text documents | |
# specified as command-line arguments. These documents are first converted to | |
# sparse vectors, represented as lists of (index, value) pairs. | |
from collections import defaultdict |
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
-- Credit to http://www.dwhworld.com/2010/08/date-dimension-sql-scripts-mysql/ | |
-- Small-numbers table | |
DROP TABLE IF EXISTS numbers_small; | |
CREATE TABLE numbers_small (number INT); | |
INSERT INTO numbers_small VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); | |
-- Main-numbers table | |
DROP TABLE IF EXISTS numbers; | |
CREATE TABLE numbers (number BIGINT); | |
INSERT INTO numbers |
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
-- credit to Akom's Tech Ruminations | |
-- http://tech.akom.net/archives/36-Creating-A-Basic-Date-Dimension-Table-in-MySQL.html | |
CREATE TABLE IF NOT EXISTS time_d ( | |
time_id INT NOT NULL auto_increment, | |
fulltime time, | |
hour int, | |
minute int, | |
second int, | |
ampm varchar(2), | |
PRIMARY KEY(time_id) |
A widget made for Dashing. This widget shows multiple animated progress bars and reacts dynamically to new information being passed in. Anything with a current state and with a projected max/goal state can easily be represented with this widget. Some sample ideas would be to show progress, completion, capacity, load, fundraising, and much more.
- Animating progress bars - Both the number and bar will grow or shrink based on new data that is being passed to it.
- Responsive Design - Allows the widget to be resized to any height or width and still fit appropriately. The progress bars will split up all available space amongst each other, squeezing in when additional progress bars fill the widget.
This will show your next GitHub milestone as a Dashing widget. Built on top of the Text widget.
To use:
-
Add the following to your
gemfile
: -
gem 'rest-client'
-
Replace the
git_token
,git_owner
, andgit_project
in git-milestone.rb as appropriate.