Skip to content

Instantly share code, notes, and snippets.

View ismailmechbal's full-sized avatar

Ismail Mechbal ismailmechbal

View GitHub Profile
@ismailmechbal
ismailmechbal / twitter_controller.rb
Created August 10, 2017 14:50
Rails -> Twitter post
class TwitterController < ApplicationController
# To change this template use File | Settings | File Templates.
def initialize
@client = Twitter::REST::Client.new do |config|
config.consumer_key = "xx"
config.consumer_secret = "xx"
config.access_token = "xx-xx"
config.access_token_secret = "xx"
end
@ismailmechbal
ismailmechbal / aliases
Created August 20, 2017 19:27
Aliases
alias pgdump="pg_dumpall >"
pgload() { psql -f $* postgres }
# ohmyzsh aliases
alias zshconfig="subl ~/.zshrc"
alias ohmyzsh="subl ~/.oh-my-zsh"
# bundler
alias be="bundle exec"
alias bi="bundle install"
require 'mechanize'
require 'sidekiq'
class BackgroundWebCrawler < Mechanize
include Sidekiq::Worker
def perform(url)
page = get(url)
@links = page.links
---
version: 2
jobs:
build:
working_directory: ~/your-app-name
docker:
- image: circleci/ruby:2.4.1
environment:
PGHOST: localhost
PGUSER: your-app-name
@ismailmechbal
ismailmechbal / nginx-tuning.md
Created May 29, 2018 13:13 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

# Route subdomains to folder
server {
server_name ~^(www\.)(?<subdomain>.+).jgefroh.com$ ;
root /var/www/jgefroh.com/$subdomain;
}
server {
server_name ~^(?<subdomain>.+).jgefroh.com$ ;
root /var/www/jgefroh.com/$subdomain;
}
@ismailmechbal
ismailmechbal / fbLinksGrabber.py
Created September 6, 2018 06:51 — forked from psychemedia/fbLinksGrabber.py
Grab likes et al for members of a Facebook group.
#This is a really simple script:
##Grab the list of members of a Facebook group (no paging as yet...)
#Lets you do things like http://blog.ouseful.info/2012/12/05/emergent-social-interest-mapping-red-bull-racing-facebook-group/
###For each member, try to grab their Likes
#USAGE
#> python fbLinksGrabber.py -group GROUPID -typ THING -FBTOKEN ETC
#THING is one of groups, likes, books etc
// PhantomJS Cheatsheet
$ brew update && brew install phantomjs // install PhantomJS with brew
phantom.exit();
var page = require('webpage').create();
page.open('http://example.com', function() {});
page.evaluate(function() { return document.title; });
@ismailmechbal
ismailmechbal / docker-clear-logs
Created January 31, 2019 15:59
Docker clear container logs
docker inspect --format='{{.LogPath}}' NAME|ID
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
echo "" > /var/lib/docker/containers/CONTAINER_ID/CONTAINER_ID-json.log
@ismailmechbal
ismailmechbal / book.rb
Created March 7, 2019 14:30 — forked from sirupsen/book.rb
Script to import books from Instapaper to Airtable. Will not work out of the box.
class Book < Airrecord::Table
class Endorser < Airrecord::Table
self.base_key = ""
self.table_name = "Endorser"
end
self.base_key = ""
self.table_name = "Books"
has_many :endorsements, class: 'Book::Endorser', column: 'Endorsements'