Skip to content

Instantly share code, notes, and snippets.

View MaherSaif's full-sized avatar

Maher Saif MaherSaif

View GitHub Profile
@MaherSaif
MaherSaif / selectize.js
Last active August 29, 2015 13:55
Selectize.js with a plugin that preserves the original option tags
/**
* sifter.js
* Copyright (c) 2013 Brian Reavis & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
define([
'jquery',
'backbone',
'underscore',
'backbone.stickit',
'selectize'
],
function ($, Backbone, _) {
# Update, upgrade and install development tools:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential git-core libssl-dev libsqlite3-dev curl nodejs nginx
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# Add rbenv to the path:
echo 'export RBENV_ROOT=~/.rbenv' >> ~/.bash_profile

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@MaherSaif
MaherSaif / copy-non-digest-assets-rails.rb
Created April 22, 2014 12:34
Create soft links as non digested assets
namespace :assets do
desc "Create soft links as non digested assets"
task soft_links: :environment do
Rake::Task['assets:precompile'].invoke
assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
manifest_path = assets.find { |f| f =~ /(manifest)(-{1}[a-z0-9]{32}\.{1}){1}/ }
manifest_data = JSON.load(File.new(manifest_path))
assets_data = manifest_data["assets"].each do |asset_name, file_name|
file_path = File.join(Rails.root, 'public/assets', file_name)
myCustomConfirmBox = function(message, callback) {
var options;
options = [
{
'label': 'Yes, Definitely',
'class': 'btn-danger',
'callback': function() {
if (typeof callback === 'function') {
return callback();
@MaherSaif
MaherSaif / Nginx-maintenance.conf
Created April 25, 2014 02:35
Nginx-maintenance
if (-f "$document_root$maintenance_file") {
set $maintenance on;
}
if ($request_uri ~* ".(css|gif|jpg|png)$") {
set $maintenance off;
}
if ($request_uri = $maintenance_file) {
set $maintenance off;
/**
* Responsive WordPress Core Theme Styles
* http://jeffsebring.com/responsive-wordpress-images/
--------------------------------------------------- */
.sticky,
.bypostauthor,
.gallery-caption {
display: normal;
}

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create Droplet

Create droplet of your liking (ubuntu 12.10 x32)

Setup DNS

On Digital Ocean, create a DNS entry for your server (xyz.com)

Make sure it has NS records that use digital oceans nameservers

<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);