Skip to content

Instantly share code, notes, and snippets.

View zotherstupidguy's full-sized avatar

Mo zotherstupidguy

  • hackspree
  • simplicity is the final achievement
View GitHub Profile
@zotherstupidguy
zotherstupidguy / api.rb
Last active August 29, 2015 14:16 — forked from noahhendrix/api.rb
module Todo
class API < Grape::API
use Rack::Session::Cookie
version 'v1', :format => :json
helpers do
def current_user
return nil if env['rack.session'][:user_id].nil?
@current_user ||= User.get(env['rack.session'][:user_id])
end
#########################################
# Very basic rack application showing how to use a router based on the uri
# and how to process requests based on the HTTP method used.
#
# Usage:
# $ rackup rack_example.ru
#
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas
# $ curl localhost:9292/ideas
@zotherstupidguy
zotherstupidguy / irccat
Last active August 29, 2015 14:21 — forked from vivien/irccat
#!/bin/sh
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
# Licensed under the terms of the GNU GPL v3, or any later version.
#Jarkko Oikarinen first introduced IRC to the world in 1988. Five years later, he clearly defined the IRC protocol in RFC 1459, which made the whole protocol much more accessible. Armed with this information, you can get a better understanding of this simple text-based protocol and learn how to connect to IRC servers without using a special client. Once you have mastered this, you should find it a trivial task to write programs that connect to IRC.
#netcat kornbluth.freenode.net 6667
#The USER command is used to set the login, user modes, and real name. If I wanted to have a login of "paul," I would type the following, followed by Enter:
#NICK zotherstupidguy\rUSER foo x x whatever

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Thu, 03 Apr 2014 02:35:55 GMT till Fri, 03 Apr 2015 02:35:55 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter((user) -&gt; user.followers &gt; 386)
@zotherstupidguy
zotherstupidguy / terminal-pinwheel.rb
Last active September 28, 2015 08:35 — forked from vy-let/terminal-pinwheel.rb
Print a clockwise-spinning pinwheel on an ANSI-compliant terminal.
#!/usr/bin/env ruby
#TODO add some colors to the circle
begin
loop do
%w( ◐ ◓ ◑ ◒ ).each do |pchar|
print "\x1b[1G\x1b[0K#{pchar} "
sleep 0.1
end
end
@zotherstupidguy
zotherstupidguy / ARCHANONIRC.md
Created September 30, 2015 09:20
A Quick Guide for Anonymous and Pseudonymous irc

##Weechat+Arch Linux+Tor ###A Quick Guide for Anonymous and Pseudonymous irc I'm going to assume you know what irc is, and generally how it works. If you haven't gotten that far watch a youtube video and try out some of the commands on an irc webclient somewhere. On Arch Linux to install Weechat you can run sudo pacman -S weechat or you can download it from the official website at http://weechat.net/download/.

You can also install Tor from the official repositories, but If you are going to be making multiple connections to irc networks and you want to keep your identities seperate, I would recommend installing the Tor Browser Bundle as well. This should be done from the Tor website, and you should check the GnuPG signature on the package before running it. The key they have been using to sign the packages with for the months that I have been verifying it i

@zotherstupidguy
zotherstupidguy / time_new.rb
Created November 15, 2015 11:40 — forked from baweaver/time_new.rb
Ox0dea's idea of getting the current time
$_=$$/$$;@_=->_{_==''?_:[*?`..?{]['. !#% & , :;<= >@_ `'=~/#{_[$.]}/]+@_[_[$_..-$_]]};_=->&_{_}[&:"#{@_['@%<#']}"];_[_[_[_['',@_['!: @@']],@_[' <!%@_=>@']][-$_-$_],@_['!=<@_']+?_+@_['&%_'],(''<<(_=$_+$_)**_**(_+$_)/(_+$_)-$_)+@_[',;%']],@_['<%`']]
$_ = $$ / $$ # PID / PID, or 1
# Translating a string of gibberish into alphabetical strings
@_ = -> _ {
_ == '' ? # If _ is blank string, return _
_ :
[
@zotherstupidguy
zotherstupidguy / record.sh
Created December 7, 2015 17:30 — forked from mjf/record.sh
Record and replay shell sessions using script(1) and scriptreplay(1)
#! /bin/sh
# Record - record shell session using script(1)
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
RECORD_PATH="$HOME/.typescripts/%Y/%m/%d"
RECORD_FILE='%H%M%S'
RECORD_TIMING_FILE="$RECORD_FILE.timing"
@zotherstupidguy
zotherstupidguy / git-compressing-and-deltas.md
Created December 21, 2015 18:06 — forked from matthewmccullough/git-compressing-and-deltas.md
Git, Compression, and Deltas - An explanation

Git Compression of Blobs and Packfiles.

Many users of Git are curious about the lack of delta compression at the object (blob) level when commits are first written. This efficiency is saved until the pack file is written. Loose objects are written in compressed, but non-delta format at the time of each commit.

A simple run though of a commit sequence with only the smallest change to the image (in uncompressed TIFF format to amplify the observable behavior) aids the understanding of this deferred and different approach efficiency.

The command sequence:

Create the repo:

@zotherstupidguy
zotherstupidguy / git-find-blob.pl
Created December 26, 2015 21:51 — forked from DaveMessina/git-find-blob.pl
git-find-blob: pass a blob SHA1 and find commits which contain it
#!/usr/bin/perl
use 5.008;
use strict;
use Memoize;
# by Aristotle Pagaltzis <http://stackoverflow.com/users/9410/aristotle-pagaltzis>
# taken from thread http://stackoverflow.com/questions/223678/git-which-commit-has-this-blob
# on 6 june 2010
my $usage =