Skip to content

Instantly share code, notes, and snippets.

View XORwell's full-sized avatar
:octocat:
XORwell@github:~$ profile

Christian Nennemann XORwell

:octocat:
XORwell@github:~$ profile
View GitHub Profile
@XORwell
XORwell / jquery_select_filter.js
Created October 11, 2013 07:50
filter select input and set the selected value
function set_select_selected(value){
$("#my_field > option").filter(function() {
return $(this).text() == value //the condition
}).prop('selected', true);
}
-# prepend example #1 (content_tag)
= f.input :date, :input_html => { :class => 'datepicker' }, :wrapper => :prepend do
= f.input_field :date
= content_tag :span, :class => 'input-group-addon' do
= content_tag :span, nil, :class => 'glyphicon glyphicon-search'
-# prepend example #2 (haml tag)
= f.input :date, :input_html => { :class => 'datepicker' }, :wrapper => :prepend do
= f.input_field :date
%span.input-group-addon
@XORwell
XORwell / simple_form_bootstrap.rb
Last active September 3, 2018 05:15
bootstrap 3 simple_form wrappers
# http://stackoverflow.com/a/18684021
# Bootstrap 3
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
function set_recurring_select_selected(){
$("#transaction_recurrence_rule > option").filter(function() {
return $(this).data('custom') == true
}).prop('selected', true);
}
@XORwell
XORwell / feed_discoverer.rb
Last active December 22, 2015 09:48
search html page for link-tags type-of rss/atom feed
class FeedDiscoverer
require 'open-uri'
# Constructor accepts options
# @param [Hash] opts
# Available options:
# * unique (default: true) - filter duplicate urls
def initialize(opts={})
@opts = {:unique => true}.merge!(opts)
end
@XORwell
XORwell / mousetrap_keybindings.js
Last active December 22, 2015 09:28
mousetrap jquery data-keybinding example
/**
* Mousetrap example
* provides data-keybinding property
*
* requirements: jQuery, Mousetrap (https://github.com/ccampbell/mousetrap)
*
* examples:
* 1: <input type='text' data-keybinding='ctrl+shift+f'> <!-- ctrl+shift+f will focus this input element -->
* 2: <button type='button' data-keybinding='ctrl+shift+b'>save</button> <!-- ctrl+shift+b will click this button -->
* 3: <input type='submit' data-keybinding='ctrl+shift+s'> <!-- ctrl+shift+s will click this input element -->
@XORwell
XORwell / soft_delete.rb
Last active December 19, 2015 05:59 — forked from brianjlandau/soft_delete.rb
rails 4 flavored version
module SoftDelete
extend ActiveSupport::Concern
included do
define_model_callbacks :soft_delete
define_model_callbacks :recover
default_scope where(deleted_at: nil)
class_eval do
class << self
alias_method :with_deleted, :unscoped
sudo aptitude install libxml2 libxslt-dev libxml2-dev libmysqlclient-dev libcurl4-openssl-dev imagemagick libmagickwand-dev libsqlite3-dev libldap2-dev libssl-dev libgsasl7 libsasl2-dev
sudo apt-get --no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev
sudo aptitude install ttf-mscorefonts-installer
@XORwell
XORwell / freesound_downloader.sh
Created November 12, 2012 06:03
freesound.org sound-samples downloader
#!/bin/bash
#############
# CONFIG
redisDB=0
redisClient="/usr/local/bin/redis-cli"
redisServer="/usr/local/bin/redis-server"
diff(){
awk 'BEGIN{RS=ORS=" "}
@XORwell
XORwell / micro_httpd.py
Created November 12, 2012 06:02
micro_httpd scanner
import re
import sys
import os
import types
from subprocess import Popen, PIPE
os.system("clear")
# show how it works
def usage():