Skip to content

Instantly share code, notes, and snippets.

View Sija's full-sized avatar

Sijawusz Pur Rahnama Sija

View GitHub Profile
@Sija
Sija / svn-index.xsl
Created January 19, 2011 09:11
XSLT file for SVN web indexes
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="*"/>
<xsl:template match="svn">
<html>
class AssertionError < Exception
end
# If `cond` is `false`, raise `exc`.
# If `exc` is not provided, `AssertionError` will be raised instead with information about the faulty expression.
# If the expression is a comparison, the result of each side of the comparison will also be shown.
macro assert(cond, exc = nil)
unless {{ cond }}
{% if exc %}
raise {{ exc }}
@Sija
Sija / .htaccess
Created July 26, 2016 00:47
no-www mod_rewrite apache .htaccess redirect
<IfModule mod_rewrite.c>
RewriteEngine on
# Preserve HTTP/HTTPS protocol in .htaccess redirects
# http://stackoverflow.com/a/20419821/601064
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=proto:http]
module MacroMagic
def initialize(**attributes)
{% for var in @type.instance_vars %}
if arg = attributes[:{{var.name.id}}]?
@{{var.name.id}} = arg
end
{% end %}
end
private def instance_var_get(name)
@Sija
Sija / build_nginx.sh
Last active March 30, 2017 00:20 — forked from MatthewVance/build_nginx.sh
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
#!/usr/bin/env bash
# make script exit if a simple command fails and
# make script print commands being executed
set -e -x
# names of latest versions of each package
export VERSION_PCRE=pcre-8.39
export VERSION_OPENSSL=openssl-1.0.2f
export VERSION_NGINX=nginx-1.9.11
startup_message off
#defbce on
#deflog on
ignorecase on
vbell on
autodetach on
altscreen on # fix for residual editor text
defutf8 on
hardcopy_append on
compacthist on
@Sija
Sija / retry.cr
Last active February 16, 2018 02:41
def retry(limit, *, backoff = nil)
attempts = 1
loop do
return yield
rescue error
raise error if attempts == limit
sleep(backoff * attempts) if backoff
attempts += 1
end
end
@Sija
Sija / angular-typeform.coffee
Last active October 8, 2018 23:34
Typeform embed module for AngularJS 1.x
'use strict'
###*
# @ngdoc overview
# @name angularTypeform
# @description
# This module contains a directive that allows you easily embed a typeform
# in your angular 1.x app taking care about state changes
###
angular.module 'angularTypeform', []
@Sija
Sija / Benchmark.h
Created February 7, 2011 22:01
Objective-C benchmark utility class used in some of my projects
//
// Benchmark.h
// Opskrifter
//
// Created by Sijawusz Pur Rahnama on 03/02/09.
// Copyleft 2009. Some rights reserved.
//
#import <Foundation/Foundation.h>
macro string_enum(name, &block)
enum {{name}}
{% for exp in block.body.expressions %}
{% if exp.is_a?(Assign) %}
{{exp.target}}
{% else %}
{{exp}}
{% end %}
{% end %}