Skip to content

Instantly share code, notes, and snippets.

View ahmednuaman's full-sized avatar
💭
I'm hiring! https://firemind.io/careers

Ahmed Nuaman ahmednuaman

💭
I'm hiring! https://firemind.io/careers
View GitHub Profile
@ahmednuaman
ahmednuaman / dynamo-import.js
Created May 17, 2017 18:42
Serverless-dynamodb-local migration to AWS script
const { basename, join } = require('path')
const { DynamoDB } = require('aws-sdk')
const { readFileSync } = require('fs')
const glob = require('glob')
const doc = new DynamoDB.DocumentClient({
region: 'eu-west-2'
})
glob(join(process.cwd(), 'seed/db/*.json'), (error, files) => {
@ahmednuaman
ahmednuaman / Vagrantfile
Created May 22, 2015 18:52
LAMP on vagrant
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/vivid64"
config.vm.network "forwarded_port", guest: 80, host: 8000
config.vm.synced_folder ".", "/var/www/html"
config.ssh.forward_agent = true
config.vm.provision "shell", inline: <<-SHELL
export DEBIAN_FRONTEND=noninteractive
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="muse"
alias zshconfig="st $HOME/.zshrc"
COMPLETION_WAITING_DOTS="true"
plugins=(git git-extras osx sublime)
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
export PATH=$HOME/.macports/bin:$HOME/.macports/sbin:$PATH
define [
'controller/base-controller'
], (BCtrl) ->
class AppController extends BCtrl
@register 'appController', [
'$scope',
'$location'
]
# or (but then big inject deps could get long)
# webm
ffmpeg -i IN -f webm -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -s 640x360 OUT.webm
# mp4
ffmpeg -i IN -acodec libfaac -ac 2 -ab 128k -vcodec libx264 -f mp4 -crf 22 -s 640x360 OUT.mp4
# ogg (if you want to support older Firefox)
ffmpeg2theora IN -o OUT.ogv -x 640 -y 360 --videoquality 5 --audioquality 0 --frontend
@ahmednuaman
ahmednuaman / crawler.coffee
Last active December 26, 2015 01:49
A script that indexes you single page application (in this case using AngularJS and RequireJS, hence removing script and style tags from the `head`) and creates `.html` files of the generated code.
fs = require 'fs'
page = (require 'webpage').create()
system = require 'system'
base = system.args[1]
indexed = []
queue = []
getHTML = () ->
tags = document.querySelectorAll 'head script, head style'
@ahmednuaman
ahmednuaman / server.js
Created June 21, 2013 13:16
CORS server in less than 33 lines (NodeJS)
var express = require('express');
var fs = require('fs');
var app = express();
var port = 8000;
app.configure(function() {
app.use(function(request, response, next) {
response.header('Access-Control-Allow-Origin', '*');
response.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
@ahmednuaman
ahmednuaman / angular-require-directive.coffee
Last active December 16, 2015 08:08
AngularJS directive on RequireJS in CoffeeScript
define [
'config'
'angular'
], (cfg, A) ->
ADirective = () ->
link: ($scope, $element, $attrs) ->
ADirective.$inject = []
@ahmednuaman
ahmednuaman / angular-require-controller.coffee
Created April 17, 2013 08:02
AngularJS controller on RequireJS in CoffeeScript
define [
'config'
'angular'
], (cfg, A) ->
class AController
@$inject = ['$scope']
constructor: (@$scope) ->
app = A.module cfg.ngApp
@ahmednuaman
ahmednuaman / controller.php
Last active December 15, 2015 20:41
Codeigniter Controller
<?php
class Controller extends CI_Controller {
public function __construct() {
parent::__construct();
}
}