Skip to content

Instantly share code, notes, and snippets.

@leomelzer
leomelzer / howto.md
Created October 22, 2012 14:38
vpnc with hybrid authentication on OS X Mountain Lion

How To

  1. Install homebrew if you don't have it already: http://mxcl.github.com/homebrew/
  2. Run brew install vpnc --hybrid
  3. Check if you already have virtual tunnel interfaces, run ls /dev/tun*. If there are none, install "Tun Tap OSX" (see below)
  4. Go to https://www.rz.uni-konstanz.de/angebote/e-mail/usermanager/ and login, then download both the certificate (you need the .pem file) and vpn profile
  5. Run openssl x509 -in <certificateFile>.pem -noout -hash
  6. Rename <certificateFile>.pem to the output of (5) with .pem as extension
  7. Move the .pem certificate to a permanent location, e.g. /etc/ssl/certs/
  8. Open /usr/local/etc/vpnc/default.conf in your favorite text editor, delete the contents
  9. Run pcf2vpnc /.pcf and paste the output to your open text editor
@kosmatov
kosmatov / image-preview-html5.js
Created August 13, 2012 13:46
Image file preview on HTML5/JS/jQuery
$('form').on('change', '.image_preview input[type="file"]', function(e) {
var files = e.target.files,
f = files[0],
reader = new FileReader(),
t = this
;
reader.onload = (function(file) {
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 20, 2025 21:04
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
require "errors"
class FacebookService
class << self
def register(data_hash)
data = AuthData.new(data_hash)
auth = User::Facebook.find_by_uid(data.uid)
if auth
raise UserBlockedError if auth.user.blocked?
@shergin
shergin / gist:1723959
Last active August 21, 2022 16:27
resolveURL
function resolveURL(baseURL, relativeURL) {
var html = document.implementation.createHTMLDocument("");
var base = html.createElement("base");
base.setAttribute("href", baseURL);
var a = html.createElement("a");
a.setAttribute("href", relativeURL);
html.head.appendChild(base);
html.body.appendChild(a);
return a.href;
}
module AccessHelper
include AuthHelper
def check_access(values = {})
acl.check! self.class.to_s, self.action_name, current_roles, values
end
def current_roles
@current_roles ||= current_user.roles_hash.keys
end
YaAcl::Builder.build do
roles do
role :admin, :name => 'Администратор'
role :remote_operator, :name => 'Удаленный Оператор'
role :editor, :name => 'Редактор'
role :taxonom, :name => 'Таксоном'
role :operator, :name => 'Оператор'
role :solo_operator, :name => 'Соло Оператор'
role :transcripter, :name => 'Транскриптер'
role :transcripts_editor, :name => 'Редактор транскриптов'
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@alinpopa
alinpopa / gist:1281448
Created October 12, 2011 15:05 — forked from vshkurin/gist:1109136
elasticsearch analyzer example - Test Queries
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",
@slayer
slayer / gist:935641
Created April 21, 2011 22:46
SQL JOIN via AREL in Rails 3
# Simple JOIN
User.joins(:account) # User -> Account
# Will produce
# SELECT `users`.* FROM `users` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id`
# Complicated JOIN
Trait.joins(:user => :account) # Trait -> User -> Account
# Will produce
# SELECT `traits`.* FROM `traits` INNER JOIN `users` ON `users`.`id` = `traits`.`user_id` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id`