Skip to content

Instantly share code, notes, and snippets.

View daniel-illi's full-sized avatar
💭
☕ 💎 🔋

Daniel Illi-Zuberbühler daniel-illi

💭
☕ 💎 🔋
View GitHub Profile
@keepitcomplicated
keepitcomplicated / gist:10731533
Last active September 9, 2018 23:38
Convert a PNG sprite to animated GIF with ImageMagick (python script)
mkdir ./gif; for f in *.png; do y=${f%.png}; convert -dispose 3 -delay 0 -deconstruct -loop 0 ./$f -crop 40x40 +repage -depth 4 ./gif/$y.gif; echo "Converting $y to GIF"; echo "—~—~—~—~—~—~—~—~—~—~—~–"; done
@amolpujari
amolpujari / ox_parsing.rb
Last active September 22, 2018 17:49
example of parsing large xml files in ruby using ox, define a handler, look up for a particular root element
require "awesome_print"
module XmlParsing
require "ox"
class Reader < ::Ox::Sax
def initialize file_path, target, target_handler
@target_handler = target_handler
@target = target
@file_path = file_path
@alex-zige
alex-zige / gist:5795358
Last active June 8, 2023 07:49
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@dschep
dschep / gist:4719355
Last active May 10, 2019 21:43
Hardening Synology DSM SSL

Synology DSM 4.1 is vulnerable to BEAST and the Lucky Thirteen attacks out of the box. Switching to RC4 ciphers makes these attacks, and any other future CBC-targeting attacks, not work.

To fix this these 2 files need to be updated:

/usr/syno/apache/conf/extra/httpd-alt-port-ssl-setting.conf
/usr/syno/apache/conf/extra/httpd-ssl.conf-common

Update them such that the line starting with SSLCipherSuite is replaced with these two lines:

SSLHonorCipherOrder On
@raws
raws / 01-install.txt
Created November 23, 2012 03:34
Install Ruby 1.9.3-p327 on a Synology DS1511+ with DSM 4.1
#########################################
### Install wget-ssl over ipkg's wget ###
#########################################
$ ipkg install -verbose_wget libidn # To get ipk URL
$ ipkg install -verbose_wget wget-ssl # To get ipk URL
$ /usr/syno/bin/wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/libidn_1.25-1_i686.ipk
$ /usr/syno/bin/wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/wget-ssl_1.12-2_i686.ipk
$ ipkg install libidn_1.25-1_i686.ipk
$ ipkg install wget-ssl_1.12-2_i686.ipk
@danneu
danneu / benchmark
Created October 29, 2012 23:04
Ox vs Nokogiri: DOM and SAX parsing comparison
# I'm no benchmark guru. Just did a bunch of:
$ time ruby <filename>
# Note: This is just an 80mb XML file with 38,000 nodes.
ox_dom.rb 4.56s user 0.78s system 93% cpu 5.714 total (550mb)
ox_dom.rb 4.58s user 0.79s system 87% cpu 6.126 total (550mb)
ox_dom.rb 4.60s user 0.80s system 87% cpu 6.140 total (550mb)
nokigiri_dom.rb 11.75s user 1.02s system 94% cpu 13.518 total (895mb)
nokigiri_dom.rb 11.36s user 1.02s system 93% cpu 13.211 total (895mb)
@daniel-illi
daniel-illi / delayed_job
Created August 6, 2012 13:20 — forked from semipermeable/delayed_job
Sys-V init script for delayed job that plays well with capistrano and rvm
#! /bin/sh
### BEGIN INIT INFO
# Provides: delayed_job
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
### END INIT INFO
@timruffles
timruffles / tag_logs.rb
Created April 2, 2012 13:34
ideas on tagging logs for rails
module PrefixedLogger
def prefixed_logger prefix
class << self
attr_reader :logger
end
@logger = ActiveSupport.TaggedLogger.new(Rails.logger)
@logger.instance_eval do
define_method :add do |severity, msg, *args, &block|
msg = "#{prefix} #{msg}"
super severity, msg, *args, &block
@daniel-illi
daniel-illi / bash_color_codes.sh
Created March 20, 2012 14:20 — forked from woods/git_svn_bash_prompt.sh
Set color bash prompt according to git/svn branch, and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set variables for various bash color codes to use in other bash scripts
#
# USAGE:
#
# 1. Save this file as ~/.bash_color_codes
# 2. Add the following line to your ~/.profile or ~/.bash_profile:
@mauricioszabo
mauricioszabo / connection_fix.rb
Created October 10, 2011 18:38 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/