Skip to content

Instantly share code, notes, and snippets.

View amanelis's full-sized avatar
🧙‍♀️

amanelis

🧙‍♀️
View GitHub Profile
@amanelis
amanelis / fork_block.c
Created December 6, 2010 07:21
The most effective un-stoppable fork bomb....ever
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
int main (void) {
struct sigaction act_int, act_ter;
sigset_t newsigset;
@amanelis
amanelis / nmap.md
Created February 4, 2013 07:02
A thorough guide to NMAP.

#NMAP Guide

  1. Basic scan to see what ports have a valid service running on them:

    nmap {host} nmap -v {host}

Pass the -v flag to print a little more information.

@amanelis
amanelis / psql.md
Last active December 12, 2015 04:58
psql default commands
\c [patter]    connect to db
\d [NAME]      describe table, index, sequence, or view
\d{t|i|s|v|S} [PATTERN] (add "+" for more detail)
             list tables/indexes/sequences/views/system tables
\da [PATTERN]  list aggregate functions
\db [PATTERN]  list tablespaces (add "+" for more detail)
\dc [PATTERN]  list conversions
\dC            list casts
\dd [PATTERN]  show comment for object

\dD [PATTERN] list domains

@amanelis
amanelis / string.java
Created August 26, 2013 22:33
String color codes
//foreground color
public static final String BLACK_TEXT() { return "\033[30m";}
public static final String RED_TEXT() { return "\033[31m";}
public static final String GREEN_TEXT() { return "\033[32m";}
public static final String BROWN_TEXT() { return "\033[33m";}
public static final String BLUE_TEXT() { return "\033[34m";}
public static final String MAGENTA_TEXT() { return "\033[35m";}
public static final String CYAN_TEXT() { return "\033[36m";}
public static final String GRAY_TEXT() { return "\033[37m";}
@amanelis
amanelis / concurrent.rb
Created September 16, 2014 16:03
Ruby concurrency using the 'concurrent' package.
# gem install concurrent-ruby
require 'rubygems'
require 'concurrent'
require 'thread'
require 'open-uri'
module Galaxy
class Ticker
def self.get_year_end_closing(symbol, year)
@amanelis
amanelis / object_space.rb
Created January 16, 2015 23:45
Count the instances of an object in the code.
class Examp
def self.obj_count
count = 0
ObjectSpace.each_object(self) do |b|
count += 1
end
return count
end
end
@amanelis
amanelis / toggle_swap
Created April 19, 2015 21:04
toggles and cleans a unix swap
#!/bin/bash
free_data="$(free)"
mem_data="$(echo "$free_data" | grep 'Mem:')"
free_mem="$(echo "$mem_data" | awk '{print $4}')"
buffers="$(echo "$mem_data" | awk '{print $6}')"
cache="$(echo "$mem_data" | awk '{print $7}')"
total_free=$((free_mem + buffers + cache))
used_swap="$(echo "$free_data" | grep 'Swap:' | awk '{print $3}')"
@amanelis
amanelis / stock_prices.rb
Last active June 24, 2016 16:27
Stock prices with a bonus of Bitcoin at the end
require 'json'
require 'open-uri'
class Stocks
def self.get_by_symbols(symbols)
return symbols.inject([]) { |memo, sym|
result = JSON.parse(open("http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol=#{sym}").read)
memo << {symbol: result['Symbol'], lastPrice: result['LastPrice']}
}
end

Keybase proof

I hereby claim:

  • I am amanelis on github.
  • I am amanelis (https://keybase.io/amanelis) on keybase.
  • I have a public key whose fingerprint is D8B5 3805 923F BBC3 E07E 8988 5A85 9D7E 303F 49EF

To claim this, I am signing this object:

@amanelis
amanelis / go_async_stock_prices.go
Created October 5, 2017 18:28
Golang async stock quote fetcher
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"sync"
"time"