Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pajtai's full-sized avatar

Peter Ajtai pajtai

  • https://www.soliddigital.com/
  • Portland, Oregon
View GitHub Profile
@pajtai
pajtai / countries.jade
Last active August 28, 2015 16:24
Two letter country code jade dropdown
select
option(selected disabled) Pick your country
option(value='US') United States
option(value='AF') Afghanistan
option(value='AX') Åland Islands
option(value='AL') Albania
option(value='DZ') Algeria
option(value='AS') American Samoa
option(value='AD') Andorra
option(value='AO') Angola
define(['baseView', 'rivetsPlugin'], function(BaseView, rivetsPlugin) {
'use strict';
var rivetsView = new BaseView({
plugins : [rivetsPlugin]
});
});
@pajtai
pajtai / redirect.js
Created June 18, 2014 21:43
Express 4 redirect www.domain.com to domain.com
express.use(function(req,res,next){
var host = req.get('host');
if(/^www\./.test(host)){
host = host.substring(4, host.length);
res.writeHead(301, {'Location':req.protocol + '://' + host + req.originalUrl,
'Expires': new Date().toGMTString()});
res.end();
} else {
next();
}
@pajtai
pajtai / migrate.js
Last active August 29, 2015 14:04
gh core user migration to using identities
/* jshint node:true */
'use strict';
var _ = require('lodash'),
fs = require('fs');
migrateUsers();
migrateContentTypes();
function migrateUsers() {
@pajtai
pajtai / data.js
Last active August 29, 2015 14:04
mongo import / export grunt task breaking it apart into one file per document using a configurable db endpoint
/*jshint node:true*/
module.exports = function (grunt) {
'use strict';
var _ = require('lodash'),
path = require('path'),
sep = path.sep,
databases = require('./databases');
grunt.registerTask('data:deleteTemp', function() {
<head>
<base href="/trailing/">
</head>
<body>
<a href="go">GO GO GO</a>
</body>
<head>
<base href="/trailing">
</head>
<body>
<a href="go">GO GO GO</a>
</body>

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@pajtai
pajtai / _ using pf on macs.md
Last active August 29, 2015 14:15
Using pf for port forwarding on macs

Since ipfw is deprecated and removed on Yosemite and Maveriks, and there are no iptables on Mac you have to use pfctl for port forwarding.

This is important in Vagrant, where usually port 8080 is exposed, but you want to be able to use port 80 on your host browser.

Here is how to setup 80 <-> 8080 port forwarding on your mac (include empty lines at the end of each file... one of them is supposedly picky about it).

After adding the two files below as root, to start (enable) port forwarding do:

sudo pfctl -ef /etc/pf-vagrant.conf
@pajtai
pajtai / mysqlDataBackup.sh
Last active August 29, 2015 14:22
Backup mysql data to a directory and clear directory of old files.
#!/usr/bin/env bash
set -e
#set -x # for debugging
MYSQL_PW=""
TTL=365
while test $# -gt 0; do
case "$1" in
-h|--help)