Skip to content

Instantly share code, notes, and snippets.

View vigo's full-sized avatar
🕶️
I may be slow to respond.

Uğur Özyılmazel vigo

🕶️
I may be slow to respond.
View GitHub Profile
@JosephPecoraro
JosephPecoraro / shell-execution.rb
Last active September 10, 2023 10:12
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Synchronous (blocking)
# Returns the output of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@tritonrc
tritonrc / ldap_admin.rb
Created January 17, 2011 19:55
Simple Sinatra based LDAP admin tool
require 'rubygems'
require 'sinatra'
require 'net-ldap'
require 'digest/sha1'
require 'base64'
require 'haml'
LDAP_HOST = 'localhost'
ADMIN_DN = 'cn=admin,dc=company,dc=com'
@jacobian
jacobian / models.py
Created February 15, 2011 18:11
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']
def __unicode__(self):
@shinzui
shinzui / tmux.conf
Created March 12, 2011 01:08 — forked from bryanl/tmux.conf
tmux.conf
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
@hughsaunders
hughsaunders / LDAPRemoteUserBackend.py
Created June 23, 2011 15:12
Django RemoteUserBackend for REMOTE_USER authentication and LDAP authorisation
# LDAP Remote User Backend for Django 1.3
# Hugh Saunders - hugh@wherenow.org
# Written for the Surgical Materials Testing Laboratory - http://smtl.co.uk
# 2011
from django.contrib.auth.backends import RemoteUserBackend
import settings as s
import ldap
class LDAPRemoteUserBackend(RemoteUserBackend):
@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@armonge
armonge / fields.py
Created July 18, 2011 14:41
A Django custom modelfield, formfield and formwidget to select and save a set of geographic coordinates using Google Maps
class GoogleMapMarker(object):
def __init__(self, latitude, longitude):
self.latitude = latitude
self.longitude = longitude
def __unicode__(self):
return '%f,%f'%(self.latitude, self.longitude)
def __len__(self):
return len(self.__unicode__())
@panthomakos
panthomakos / group.rb
Created September 20, 2011 22:57
Custom Error Messages in Ruby
class Group
module Error
class Standard < StandardError; end
class AlreadyAMember < Standard
def message
"You are already a member of this group."
end
end
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@fairchild
fairchild / Gemfile
Created December 7, 2011 09:58
An example sinatra omniauth client app
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)
gem 'thin'