Skip to content

Instantly share code, notes, and snippets.

View soomtong's full-sized avatar
😇

YoungTaek soomtong

😇
View GitHub Profile
@sente
sente / formatXML.js
Last active April 4, 2024 12:20
javascript to format/pretty-print XML
The MIT License (MIT)
Copyright (c) 2016 Stuart Powers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@adrianbravo
adrianbravo / encrypt-decrypt.js
Created September 22, 2011 00:08
Basic Node.js crypto cipher/decipher example.
var crypto = require('crypto')
, key = 'salt_from_the_user_document'
, plaintext = 'password'
, cipher = crypto.createCipher('aes-256-cbc', key)
, decipher = crypto.createDecipher('aes-256-cbc', key);
cipher.update(plaintext, 'utf8', 'base64');
var encryptedPassword = cipher.final('base64')
decipher.update(encryptedPassword, 'base64', 'utf8');
@jbroadway
jbroadway / Slimdown.md
Last active February 5, 2024 10:43
Slimdown - A simple regex-based Markdown parser.
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 29, 2024 08:12
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@balupton
balupton / cors.js
Created September 11, 2012 05:21
Acheiving CORS via a Node HTTP Server
// Create our server
var server;
server = http.createServer(function(req,res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
res.writeHead(200);
@kouphax
kouphax / Darcula.itermcolors
Created January 24, 2013 22:27
Jetbrains IntelliJ IDEA Darcula Theme ported to iTerm2 colour scheme. WIP.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.16300885379314423</real>
<key>Green Component</key>
<real>0.16304571926593781</real>
@joaoneto
joaoneto / login.test.js
Created March 13, 2013 13:49
Login session test with mocha
var request = require('supertest'),
should = require('should'),
app = require('../server');
var Cookies;
describe('Functional Test <Sessions>:', function () {
it('should create user session for valid user', function (done) {
request(app)
.post('/v1/sessions')
@nickrw
nickrw / volsay.sh
Created April 19, 2013 12:43
volsay: Wrapper around OSX's `say' command, which sets the system volume to the requested level, then restores volume / mute state once speech is complete.
#!/bin/bash
function usage() {
echo "usage: $0 <volume (0-100)> <say args...>"
echo
echo "Unmutes and sets the system volume to volume%, passing the remaining"
echo "arguments to the OSX \`say' command, restoring volume / mute setting"
echo "to previous values after the speech has completed."
exit 1
}
#!/usr/bin/env node
/**
npm install cheerio request step
chmod +x urlparser.js
./urlparser.js
*/
var cheerio = require('cheerio')
, request = require('request')
@quezo
quezo / CipherTimer.js
Created June 27, 2013 20:34
This was a small test I created to determine the fastest Cipher (an algorithm used for encryption/decryption) available in NodeJS. There was a huge variation between the best (aes-128-ofb at 305.6934) and the worst (bf-ecb at 1024.3660).
var crypto = require('crypto');
var _ = require('underscore')._;
// Returns elapsed time in milliseconds
function get_elapsed_time(startTime) {
var diff = process.hrtime(startTime);
// (seconds to milliseconds) + (nanoseconds to milliseconds)
return (diff[0] * 1000) + (diff[1] / 1000000);
}