Skip to content

Instantly share code, notes, and snippets.

View mitramejia's full-sized avatar

Mitra Mejia mitramejia

View GitHub Profile
@mitramejia
mitramejia / post-recieve
Last active April 15, 2016 18:37
post-receive
#!/usr/bin/env ruby
# post-receive
# 1. Read STDIN (Format: "from_commit to_commit branch_name")
from, to, branch = ARGF.read.split " "
# 2. Only deploy if master branch was pushed
if (branch =~ /master$/) == nil
puts "Received branch #{branch}, not deploying."
exit
@mitramejia
mitramejia / docker-compose.staging.yml
Last active October 26, 2016 21:53
Docker Compose config file for production apps using Geniem's wp-project template
##
# Nodejs container which installs and builds all frontend assets
##
#frontend:
# image: devgeniem/node-assets-builder
# volumes_from:
# - data
# command: /bin/bash -c "cd /var/www/project/web/app/themes/THEMENAME && npm install && ./node_modules/webpack/bin/webpack.js"
##
@mitramejia
mitramejia / pre-push
Created December 4, 2016 17:08
pre-push git hook, a ruby script to run behat tests before a git push is executed. If tests pass git push will be allowed
#!/usr/bin/env ruby
require 'colorize'
require 'git'
# Get working directory and make git read it
working_dir = "/Users/yourname/app"
git = Git.open working_dir
# Get current git branch
current_branch = git.branches.select { |branch| branch.current == true }.first
@mitramejia
mitramejia / deploy.rb
Created December 24, 2016 16:18
Deploy trellis projects in a Continuous Integration manner
#!/usr/bin/env ruby
require 'colorize'
require 'git'
# Public: A Class to deploy trellis projects in a Continuous Integration manner.
class Deployment
# Modify these to match your project
TESTS_DIR = '/your/behat/tests/directory'.freeze
TRELLIS_DEPLOY_SCRIPT_DIR = '/path/to/trellis/deploy.sh/script'.freeze
@mitramejia
mitramejia / random-number-between-two.scss
Created April 3, 2017 17:43
Get a random number between two numbers in scss
// Given two numbers return the biggest one
@function get-biggest-num-between($a, $b) {
$c: null;
@if ($a > $b) {
$c : $a;
}
@if ($a < $b) {
$c : $b;
}
@else if ($a = $b){
@mitramejia
mitramejia / mitracoin.js
Last active January 19, 2018 20:19
Simple Blockchain made with JS
const SHA256 = require('crypto-js/sha256');
class Block {
constructor(index, timestamp, data, previousHash = ''){
this.index = index;
this.timestamp = timestamp;
this.data = data;
this.previousHash = previousHash;
this.hash = this.calculateHash();
this.nonce = 0;
@mitramejia
mitramejia / example.sass
Created March 8, 2018 16:18 — forked from brod-ie/example.sass
respond-to() SASS mixin for Bootstrap 3 grid system.
.profile-pic {
float: left;
width: 250px;
@include respond-to(xs) {
width: 100%;
}
@include respond-to(sm) {
width: 125px;
}
@mitramejia
mitramejia / gist:a1a6546b84cadf68e5944b0879407930
Created March 12, 2018 16:38
Some times we need to add a full width containers (which spans 100% of window) inside a container which has a fixed width and aligned center
<div class="container" style="width: 750px; margin: 0 auto;">
<div class="row-full">
--- Full width container ---
</div>
</div>
.row-full{
@mitramejia
mitramejia / steps.md
Created March 29, 2018 18:16 — forked from travisvalentine/steps.md
Setup Facebook app to test authentication locally (aka, setting up App Domain)

Note: I had issues with setting up my Facebook app so authentication would work. I'd receive the error at the bottom, and it took me a while to figure out what was wrong

Here are the steps I took:

  • Go to http://developers.facebook.com/, create, and setup your app
  • When inside the dashboard, click "Settings"
  • Click "Add Platform"
  • Choose website (for authentication via the web app)
  • Add http://localhost:3000/ as "Site URL" (and "Mobile URL" if necessary)
  • Add localhost to "App Domains" above
@mitramejia
mitramejia / react-typescript.md
Created April 17, 2018 13:11 — forked from juhaelee/react-typescript.md
React + Typescript Cheatsheet

React + Typescript Cheatsheet

Setup

If you use atom... download & install the following packages:

What are Typescript type definition files? (*.d.ts)