Skip to content

Instantly share code, notes, and snippets.

// Server side, BarController
module.exports = {
foo: function (req, res) {
res.view('foo');
},
save: function (req, res) {
Bar.create({
name: 'bar'
@awsp
awsp / groupBy
Last active April 4, 2021 08:45
Javascript - multiple groupBy function
/**
* Javascript -
* Array multiple groupBy function
* Forked from http://codereview.stackexchange.com/questions/37028/grouping-elements-in-array-by-multiple-properties
*
* Usage:
* var list = [
* { foo: "bar", id: 1 },
* { foo: "barbar", id: 2 },
* { foo: "bar", id: 1 },
#
# A virtual host using mix of IP-, name-, and port-based configuration.
# This is based on using Homebrew for OS X. You can use this in other
# cases though, but you'll likely need to adjust some of the paths below.
#
server {
# Replace this port with the right one for your requirements
# listen 80 [default|default_server]; #could also be 1.2.3.4:80
@awsp
awsp / replaceLast
Created September 30, 2014 19:28
Replace last instance of a token occurance.
/**
* Replace last occurance of a token
* Slightly modified from SO answer.
* http://stackoverflow.com/a/2729681/2167601
*
* @param needle
* @param target
* @return string
*/
String.prototype.replaceLast = function (needle, target) {
@awsp
awsp / randomChars
Last active August 29, 2015 14:07
Generate Random Number
// Generate random characters,
// http://stackoverflow.com/a/8084248/2167601
var randomChars = function (length) {
if (typeof length === 'undefined') {
length = 8;
}
return (Math.random() +1).toString(36).substr(2, length);
};
@awsp
awsp / node.js installation
Last active August 29, 2015 14:11
Installing Node.js
$ cd /usr/local/src
$ wget http://nodejs.org/dist/v0.10.33/node-v0.10.33.tar.gz
$ tar -xvzf node-v0.10.33.tar.gz
$ cd node-v0.10.33
$ ./configure
$ make
$ sudo make install
$ which node
@awsp
awsp / .htaccess
Last active September 29, 2015 02:10
Disallow access to .git and .svn on Apache
RedirectMatch 404 (?i)\.git
RedirectMatch 404 (?i)\.svn
# all hidden file
RedirectMatch 404 (?i)/\..+
@awsp
awsp / gist:11aa19e88302f570ea57
Created March 13, 2015 02:49
Disable directory listing to .git .svn on IIS
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment=".git" />
<add segment=".svn" />
</hiddenSegments>
</requestFiltering>
</security>
tell application "iTunes"
activate
set newPreset to make new EQ preset
set name of newPreset to "Perfect"
set band 1 of newPreset to 3
set band 2 of newPreset to 6
set band 3 of newPreset to 9
set band 4 of newPreset to 7
set band 5 of newPreset to 6
set band 6 of newPreset to 5
tell application "iTunes"
activate
set newPreset to make new EQ preset
set name of newPreset to "Eargasm Explosion"
set band 1 of newPreset to 3
set band 2 of newPreset to 6
set band 3 of newPreset to 9
set band 4 of newPreset to 7
set band 5 of newPreset to 6
set band 6 of newPreset to 5