Skip to content

Instantly share code, notes, and snippets.

View GustJc's full-sized avatar

Gustavo Jaruga Cruz GustJc

View GitHub Profile
@GustJc
GustJc / colab_gitlab_script_v3.rb
Created March 11, 2015 14:33
Updates database, pass: <dbname true> to auto-fix the namespaces Name field if the same as the Path field
#!/usr/bin/env ruby
gitlab_db = 'gitlabhq_production'
auto_alter_namespace_name = false
if ARGV[0]
gitlab_db = ARGV[0]
end
if ARGV[1]
if ARGV[1] =~(/^(true|t|yes|y|1)$/i)
auto_alter_namespace_name = true
@GustJc
GustJc / sanity_check.rb
Created March 11, 2015 14:31
Checks for duplicated users and invalid usernames
#!/usr/bin/env ruby
gitlab_db = 'gitlabhq_production'
if ARGV[0]
gitlab_db = ARGV[0]
end
puts "Using gitlab database as: #{gitlab_db}"
require 'pg'
@GustJc
GustJc / colab_gitlab_script.rb
Created March 10, 2015 20:32
Correct the gitlab usernames
#!/usr/bin/env ruby
require 'pg'
conn = PG::Connection.new(:dbname => 'colab', :user => 'postgres')
colab_users = conn.exec('SELECT USERNAME,EMAIL FROM ACCOUNTS_USER')
conn = PG::Connection.new(:dbname => 'gitlabhq_production', :user => 'postgres')
gitlab_users = conn.exec('SELECT USERNAME,EMAIL, ID FROM USERS')
@GustJc
GustJc / colab_gitlab_script_v2.rb
Created March 10, 2015 20:31
Correct the gitlab usernames.
#!/usr/bin/env ruby
gitlab_db = 'gitlabhq_production'
if ARGV[0]
gitlab_db = ARGV[0]
end
puts "Using gitlab database as: #{gitlab_db}"
require 'pg'
@GustJc
GustJc / UriUnsolved_v3.py
Last active August 29, 2015 13:59
Busca exercicios e questões do URI para comparações
import urllib3
import time
from lxml import etree
import pickle
import sys
from random import randint
import random
import os
from Queue import Queue
import workerpool
import urllib3
import time
from lxml import etree
import pickle
import sys
from random import randint
import random
import os
@GustJc
GustJc / PyCrawlerURI.py
Last active December 26, 2015 14:09
URI Judge simple WebCrawler for reading exercises offline.
import urllib2
from urllib2 import HTTPError
from urllib2 import URLError
import os.path
import lxml.html
ex_number = 1001
while True:
try: