Skip to content

Instantly share code, notes, and snippets.

@hothero
hothero / clone-all-repos
Created June 12, 2022 08:10
clone all repos in an organization via gh CLI
gh repo list {org_name} --language Go --limit 500 | grep -v ct- | awk '{print $1}' | xargs -I '$' git clone 'git@github.com:$.git'
@hothero
hothero / rsa_ecb_pkcs1.go
Created May 6, 2018 13:56
RSA/ECB/PKCS1Padding imnplementation by Golang (can work with JAVA, C#, etc.)
package main
import (
"bytes"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"errors"
@hothero
hothero / aes_cbc_pkcs5.go
Last active March 30, 2024 02:53
AES/CBC/PKCS5Padding implementation by Golang (can work with JAVA, C#, etc.)
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"fmt"
)
@hothero
hothero / db.rake
Last active June 30, 2017 10:19 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump -h #{host} -U #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@hothero
hothero / wakeupheroku.php
Created May 15, 2013 13:36
get webpage content for waking up heroku server
<?php
$urls = array("http://webcontest.mirlab.org", "http://webprogramming.mirlab.org");
for ($i=0; $i<count($urls); $i++)
{
getContent($urls[$i]);
}
function getContent($url)
{
@hothero
hothero / woconverter.rb
Last active December 16, 2015 02:19
Wordpress to Octopress Convertor
require 'fileutils'
require 'date'
require 'yaml'
require 'rexml/document'
require 'ya2yaml'
require 'uri'
include REXML
doc = Document.new(File.new(ARGV[0]))
@hothero
hothero / filezilla_useradd_script.rb
Created May 31, 2012 07:25
Script for creating amount of Filezilla Server User account configuration
require 'digest/md5'
num = 36 # total number we want to create
user_info = File.new('user_info.txt', 'w+')
config_content = File.new('config_content.txt', 'w+')
(1..num).each do |t_num|
team_name = "team#{t_num}"
passwd = (0...6).map{97.+(rand(25)).chr}.join # random a string for password
user_info.write("#{team_name}\t#{passwd}\n")
passwd = Digest::MD5.hexdigest(passwd) # encoding string to md5 format