Skip to content

Instantly share code, notes, and snippets.

View ajmalafif's full-sized avatar
💻

Ajmal Afif ajmalafif

💻
View GitHub Profile

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
var gulp = require('gulp');
var paths = {
scripts: ['app/scripts/**/*.js'],
html: ['app/index.html', '!app/test.html'],
dist: ['dist/']
};
gulp.task('default', function(){
gulp.src(paths.scripts.concat(paths.html))
- var paths = [], files = []; function recursiveTree(obj) { if (typeof obj == "object" && !obj.length) { for (item in obj) { if (item === "contents") { recursiveTree(obj[item]); } else if (item != "data") { paths.push(item); recursiveTree(obj[item]); paths.splice(paths.length-1, 1); } } } else if (typeof obj == "object") { for (i in obj) { var file = obj[i]; if (/(\.html$)/.test(file)) { paths.push(file); files.push("/" + paths.join("/")); paths.splice(paths.length-1, 1); } } } }; recursiveTree(public);
xml
urlset(xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
- for(i in files) {
url
loc= files[i]
priority 0.5
- }
# recursively delete original files after a git merge failure
find . -name *.orig -delete

Ghost is an open source platform for blogging founded by John O'Nolan and Hannah Wolfe. It's a node.js application and therefore works great in conjunction with nginx. This guide will will help you create a high performance nginx virtual host configuration for Ghost.

"Don't use #nodejs for static content" - @trevnorris. If #nginx isn't sitting in front of your node server, you're probably doing it wrong.

— Bryan Hughes (@nebrius) August 30, 2014
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

The node.js application runs on a port on your server. We can configure nginx to proxy to this port and also cache so that we don't need to rely on express, the default n

@ajmalafif
ajmalafif / commands.md
Last active August 29, 2015 14:08 — forked from weotch/commands.md

Since you can't ssh from PagodaBox (the binary isn't installed), you can't rsync or scp between servers. Thus you need to copy them locally and then upload back up

  1. Enable ssh in PB for both servers.
  2. SSH to the first server and tar the uploads dir: tar -cvf uploads.tar shared/public/uploads. Not bothering with zipping causing it would take along time and it's all binary so I don't expect much compression help.
  3. Download the uploads.tar file to your comp.
  4. Delete uploads.tar file from server.
  5. Upload uploads.tar file to the root of second server.
  6. Connect to second server via SSH
  7. Uncompress it: tar -xvf uploads.tar
  8. Delete uploads.tar file from the second server
@ajmalafif
ajmalafif / post-checkout.rb
Last active August 29, 2015 14:08 — forked from gavinballard/post-checkout.rb
[git] — post checkout hook
#!/usr/bin/env ruby-rvm-env 1.9.3
require 'yaml'
# Get the "type" of checkout from the arguments Git passes to us.
# Possible values for this are "0" for a file-only checkout (which we dont' care about)
# or "1" for a full branch checkout (which we do).
checkout_type = ARGV[2]
if checkout_type == "1"
#!/usr/bin/env ruby
# If you're not using rbenv in this script's dir, you may wanna run
# these as `sudo gem install ruby-trello`, etc.
['ruby-trello', 'dotenv'].each do |gem_name|
begin
gem gem_name
rescue LoadError
puts "Running `gem install #{gem_name}`..."
puts "If this takes too long, you may want to run it manually, as `sudo` if needed."
def self.find_for_oauth(auth, signed_in_resource = nil)
# Get the identity and user if they exist
identity = Identity.find_for_oauth(auth)
user = identity.user
user = signed_in_resource if user.nil?
if user.nil?
# Get the existing user by email if the OAuth provider gives us a verified email
/**
* For more information see this tutorial: http://blog.webbb.be/use-jekyll-with-gulp/
*
* Libs import
* --> How to install? npm install --save-dev gulp-minify-html
* @type {[type]}
*/
var gulp = require('gulp'),
path = require('path'),