Skip to content

Instantly share code, notes, and snippets.

View ismk's full-sized avatar

Ismail Kalimi ismk

View GitHub Profile
@ismk
ismk / normalizer.rb
Last active August 29, 2015 14:17
Script to reencode video files with volume gain
@codecs = {
"flv"=>"-codec:v libx264 -crf 19",
"mov"=>"-c:v copy -c:a h264 -acodec aac -strict -2",
"avi"=>"-c:v copy -c:a libmp3lame -q:a 2",
# this is left to be done
"mp4"=>"-c:v copy -b:a 192k -c:a aac -strict -2",
"wmv"=>"-codec:v libx264 -crf 23 -c:a libfaac -q:a 100"
@ismk
ismk / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ismk
ismk / python_resources.md
Last active August 29, 2015 14:19 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@ismk
ismk / Calculating_Sequence.rb
Created December 17, 2015 05:01
Sequence Solution
# Okay lets first implement the base cases and then we can tackle higher numbers
# First we need to have the condition thats stops the sequence, i.e when n is 1
while(n != 1) do
# the sequence here
end
# Now for the rules to be implemented
# n → n/2 (n is even)
# n → 3n + 1 (n is odd)
@ismk
ismk / tournamentDBHelper.java
Created March 10, 2017 20:20
tournament db helper class
public Tournament getOngoingTournament() {
Tournament tournament = null;
SQLiteDatabase db = this.getReadableDatabase();
String sql = "SELECT "
+ COLUMN_TOURNAMENT_ID + ","
+ COLUMN_STATUS + ","
+ COLUMN_FIRST_USER + ","
+ COLUMN_FIRST_PRIZE + ","
+ COLUMN_SECOND_USER + ","
@ismk
ismk / NokogiriXPathNamespaces
Created July 31, 2018 22:23 — forked from Ameeda/NokogiriXPathNamespaces
Selecting elements in some namespace using Nokogiri with XPath
2 ways to extract elements from within XML namespaces using Nokogiri
When trying to select elemenets in the default namespace, e.g. "xmlns= http://www.w3.org/2005/Atom", try the following two ways. Note the xmlns=" attribute on entry element:
Original xml:
Nokogiri::XML(@xml_string).xpath("//author/name").each do |node|
puts node
end
1. Define a namespace context for your XPath expression and point your XPath steps to match elements in that namespace. Define a namespace-to-prefix mapping and use this prefix (a) in the XPath expression.
@ismk
ismk / osx_setup.md
Created October 10, 2019 03:09 — forked from millermedeiros/osx_setup.md
Mac OS X setup

Setup Mac OS X

Edit: I've done the same process every couple years since 2013 (Mountain Lion, Mavericks and High Sierra).

I just replaced the hard drive of my mbp and decided to do a clean install of Mountain Lion (10.8.5) since I was still using Snow Leopard (10.6.8).

I kinda regret for not using Boxen to automate the process, but TBH I have this laptop for almost 3yrs and this is the first

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

API workthough

  1. Open a browser

    # start an instance of firefox with selenium-webdriver
    driver = Selenium::WebDriver.for :firefox
    # :chrome -> chrome
    # :ie     -> iexplore
    
  • Go to a specified URL