Skip to content

Instantly share code, notes, and snippets.

@genewoo
genewoo / Gitlab Public Access
Last active December 16, 2015 22:29
Enable user to access public project raw files and project without be a member of that project
commit 458580f297fbda26dc4b0f49cf18b231d1010597
Author: Gene Wu <genewoo_AT_gmail.com>
Date: Sun Apr 28 02:03:42 2013 -0700
Enable user to access public project
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 32b1246..89ab816 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@genewoo
genewoo / gitlab_ldap.sh
Created April 28, 2013 07:19
Login LDAP Authentication GitLab instance by CLI and Fetch RAW File by curl. Since LDAP authentication will create the account for you, so it's very useful to fetch file from GitLab.
#!/bin/sh
BASEURL=http://git
USERNAME=DOMAIN_USER
USERPASS=DOMAIN_PASSWORD
RAW_FILE=RAW_FILE_URI
# login
curl -s -c cookies.txt -d "username=$USERNAME&password=$USERPASS" $BASEURL/users/auth/ldap/callback -o /dev/null
curl -s -c cookies.txt -b cookies.txt $BASEURL$RAW_FILE
@genewoo
genewoo / export_user_email.rb
Created April 2, 2013 08:42
Send email to all GitLab User, output will be a list user email address. You can put in your mail client and sent to all of your gitlab users
require 'net/http'
require 'json'
YOUR_API_KEY="INPUT YOUR ADMIN PRIVATE_KEY HERE"
YOUR_SERVER_HOST="YOUR HOST"
response = Net::HTTP.get_response(YOUR_SERVER_HOST, "/api/v3/users?private_token=${YOUR_API_KEY}")
users = JSON.parse response.body
puts users.map{|user| user["email"] + ";"}
@genewoo
genewoo / irb_verbosity_toggle.rb
Last active December 13, 2015 16:59
enable disable irb echo
# via http://tagaholic.me/2009/05/29/exploring-how-to-configure-irb.html#echo
def irb_verbosity_toggle
irb_context.echo ? irb_context.echo = false : irb_context.echo = true
end
@genewoo
genewoo / webtail.py
Created August 19, 2012 00:49 — forked from maximebf/webtail.py
Web tail / tail -f as a webpage using websocket
#!/usr/bin/python
# Equivalent of "tail -f" as a webpage using websocket
# Usage: webtail.py PORT FILENAME
# Tested with tornado 2.1
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
import tornado.httpserver
@genewoo
genewoo / folder_helper.rb
Created December 29, 2011 15:11
My Folder helper
def folder_exists!(folder)
folder = File.expand_path(folder)
target = ""
folder.split(File::SEPARATOR).each{ |path|
target = "/" if target.empty? && path.empty? #Unix environment
target = File.join(target, path).to_s
create_folder(target) if path.empty?
}
target
end