Skip to content

Instantly share code, notes, and snippets.

View amireh's full-sized avatar

Ahmad Amireh amireh

View GitHub Profile
@amireh
amireh / default-appendix-html-appendix_entry.erb
Last active December 12, 2015 01:18
The template overrides and the AppendixObject source.
<h3><%= object.title %></h3>
<%= yieldall :index => 0 %>
require 'bundler'
Bundler.require(:default)
# Currency
#
# A transaction currency.
#
class Currency
#!/usr/bin/env ruby
# usage: /path/to/script.rb CANVAS_API_TOKEN COURSE_ID [HOST]
# -
# the script should output "true" and "false" on two consecutive lines
# (make sure you `chmod +x` the script before attempting to run it)
require 'net/http'
require 'uri'
require 'json'
@amireh
amireh / gist:3494268
Created August 28, 2012 02:05
Busted Arabic localization
s:set_namespace("ar")
-- "Pending: test.lua @ 12 \n description
s:set("output.pending", "عالِق")
s:set("output.failure", "فَشَل")
s:set("output.failure", "نَجاح")
s:set("output.pending_plural", "عالِق")
s:set("output.failure_plural", "إخْفاقات")
s:set("output.success_plural", "نَجاحات")
@amireh
amireh / karazeh-release_manifest.template.xml
Created August 14, 2012 21:09
Karazeh v2 - Release manifest template
<karazeh>
<!-- the version tag isn't used, it's there for the developer only -->
<release version="0.1.0">
<!-- a text file of change list to be optionally downloaded and displayed to the user -->
<meta name="changelist" value="http://localhost:9333/patches/changelist/0.1.0.txt" />
<!-- whether the patch is archived or not -->
<meta name="archived" value="false" />
<!-- URI to the patch archive (tarball, zip, etc.) -->
<meta name="archive-url" value="" />
@amireh
amireh / karazeh-version_manifest.template.xml
Created August 14, 2012 21:07
Karazeh v2 - Version manifest template
<karazeh>
<!--
<identity></identity>
These entries mark the files that will be used to validate
the application's integrity; the accumulative checksum
of all the files listed will be used to identify the
application's current version.
-->
@amireh
amireh / trim.c
Created July 9, 2011 17:31
Trim strings in C
#include <stdio.h>
#include <malloc.h>
#include <string.h>
int is_ws(char c) {
return c == ' ';
}
int trim(const char* src, char** dst) {
if (strlen(src) == 0)
@amireh
amireh / graph.js
Created December 14, 2010 21:27
OOP JavaScript
function Graph() {
self = this;
this.nodes = [];
this.edges = [];
this.levels = [];
this.step = { level: -1, x: 0, y: 0 };
this.root = null;
this.last_path = null;
@amireh
amireh / get_request_progress.rb
Created December 10, 2010 10:46
Track progress of an HTTP GET request while following HTTP Redirections
def fetch(link, level, options = {})
raise RuntimeError, 'HTTP redirect too deep' if level == 0
buf = OpenURI::Buffer.new
uri = URI.parse(link)
http = Net::HTTP.new(uri.host, uri.port)
response = nil
http.start {
req = Net::HTTP::Get.new(uri.request_uri)