Skip to content

Instantly share code, notes, and snippets.

@andineck
andineck / buffer-gt-0x80.js
Last active August 29, 2015 14:18
Buffer.toString() encoding
var assert = require('assert');
var buf, buf2;
buf = new Buffer([0x00, 0x41, 0x7f]);
buf2 = new Buffer(buf.toString());
//console.log(buf, buf2);
// -> <Buffer 00 41 7f> <Buffer 00 41 7f>
assert(buf2.equals(buf), 'buffer with normal acii chars can be converted to string and back');
assert.equal(buf2.length, 3);
@andineck
andineck / file.ps1
Created April 22, 2015 13:04
powershell read write file
$filePath = "test.txt"
# write append to file
echo 'halloo' >> $filePath
# write empty file
echo $null > $filePath
@andineck
andineck / email.ps1
Created April 23, 2015 07:54
powershell send email
# email-subscribers.dat is a file with email adresses separated by newline
# SmtpServer must be provided
$emails = Get-Content email-subscribers.dat
foreach($email in $emails) {
Send-MailMessage -From "me@you.com" -To $email -Subject "howzit" -Body "long time no see" -SmtpServer "smtp.google.com"
}
@andineck
andineck / 1 readme.md
Last active August 29, 2015 14:19
Javascript Member Variables done properly

javascript member variables

know the difference between shared and instance specific member variables in javascript.

@andineck
andineck / path-to-regexp#54.js
Created May 12, 2015 20:21
path-to-regexp PR54 tests.
// patch: "path-to-regexp": "git://github.com/pillarjs/path-to-regexp.git#asterisk-match"
var patch = require('./patch/node_modules/path-to-regexp');
// old: "path-to-regexp": "^0.1.3"
var old = require('./0.1.3/node_modules/path-to-regexp');
var assert = require('assert');
// routes: 0: route, 1: path, 2: param
var routes = [
['*', '/test/route/aA/bB/cC', '/test/route/aA/bB/cC'],
@andineck
andineck / 1 badass-grid.markdown
Last active August 29, 2015 14:21
badass grid
@andineck
andineck / 1 readme.md
Last active August 29, 2015 14:22
shared module

node.js module hickups

modules in node are great. sharing them in npm is even better.

  • make sure you understand, that module when you require the same module from within the same directory, you get the reference to the same thing.
  • if you require the same module in files wich are located in different directories, you get two new module instances.

run

node b.js
@andineck
andineck / 1 readme.md
Last active August 29, 2015 14:23
javascript variables

understand javascript variables

run:

node variables.js
@andineck
andineck / update_ubuntu.sh
Created August 17, 2015 05:11
update ubuntu
sudo apt-get update # Fetches the list of available updates
sudo apt-get upgrade # Strictly upgrades the current packages
sudo apt-get dist-upgrade # Installs updates (new ones)
@andineck
andineck / 0-readme.md
Last active September 2, 2015 08:27
github: add repo via command line

github cmd

  1. how to create and init a git repository
  2. how to create and init a git repository for an organization