Skip to content

Instantly share code, notes, and snippets.

View ismailmechbal's full-sized avatar

Ismail Mechbal ismailmechbal

View GitHub Profile
@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
# 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 / nginx-tuning.md
Created May 29, 2018 13:13 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

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.

---
version: 2
jobs:
build:
working_directory: ~/your-app-name
docker:
- image: circleci/ruby:2.4.1
environment:
PGHOST: localhost
PGUSER: your-app-name
require 'mechanize'
require 'sidekiq'
class BackgroundWebCrawler < Mechanize
include Sidekiq::Worker
def perform(url)
page = get(url)
@links = page.links
@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"
@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
class FacebookController < ApplicationController
def initialize
#specify access_token here
@access_token = 'X'
#Picking the graph api object from kaola gem
@graph = Koala::Facebook::API.new(@access_token)
end
def page_wall_post
https://graph.facebook.com/oauth/access_token?client_id=<APP_ID>&client_secret=<APP_SECRET>&grant_type=fb_exchange_token&fb_exchange_token=<SHORT_LIVE_ACCESS_TOKEN>
Source
https://www.geekytidbits.com/facebook-posts-from-rails/
@ismailmechbal
ismailmechbal / ahoy_base.rb
Created June 19, 2017 15:21 — forked from jabbett/ahoy_base.rb
Setting up Ahoy models to use a separate datastore
module Ahoy
class AhoyBase < ActiveRecord::Base
establish_connection DB_STATS
self.abstract_class = true
end
end