Skip to content

Instantly share code, notes, and snippets.

View alexrios's full-sized avatar
🦎
Zigging around

Alex Rios alexrios

🦎
Zigging around
View GitHub Profile
@alexrios
alexrios / robot.js
Created December 10, 2012 21:33
Alex
// Conventions:
// We use angles in degrees in clock-wise fashion
RobotHelpers = {};
MathHelpers = {};
RobotHelpers.cannon_rotation_direction = {};
RobotHelpers.shoot = {};
RobotHelpers.target = {};
RobotHelpers.moving_direction = {};
@alexrios
alexrios / robot.js
Created December 11, 2012 00:50
DeathAng3l2
// Conventions:
// We use angles in degrees in clock-wise fashion
RobotHelpers = {};
MathHelpers = {};
RobotHelpers.cannon_rotation_direction = {};
RobotHelpers.shoot = {};
RobotHelpers.target = {};
RobotHelpers.moving_direction = {};
@alexrios
alexrios / EasyOrderBy.md
Last active December 11, 2015 02:18
Java "order by" made easy
//Smart use of enums
public enum DeviceComparator implements Comparator<Device> {
 
    ID {
        public int compare(Device o1, Device o2) {
            return Integer.valueOf(o1.getId()).compareTo(o2.getId());
        }},
    NAME {
        public int compare(Device o1, Device o2) {
#!/bin/bash
# This script is edited by Brice Dutheil
# See there in french http://blog.arkey.fr/2012/07/30/script-pour-installer-le-jdk-5-sur-macosx-lion/
# Translate button is broken for now, please use Google to translate this website.
#
# 2012/08/25 This script didn't behave correctly when ran on 10.8.1
# Added recommendation to always run this script after updates such as Java, XCode, OSX, etc.
#
# 2O12/07/29 Added Mountain Lion support => Choose the 64bit JVM !
@alexrios
alexrios / Sublime2_From_Terminal.md
Created February 23, 2013 16:19
Opening sublime text 2 from OSX terminal

Create symlink called sublime

ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

Open your bash profile

open ~/.bash_profile

Alter PATH

export PATH=/usr/local/bin:$PATH

Restart bash

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class JCheckBoxActionListener {
public static void main(String args[]) {
JFrame frame = new JFrame("Iconizing CheckBox");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JCheckBox aCheckBox4 = new JCheckBox("Stuffed Crust");
@alexrios
alexrios / NearbyWords.java
Created November 25, 2014 20:43
Facebook's How to Crush Your Coding Interview. Problem: Write a function that given a string, returns all nearby words. You are given the following helper functions: Set<String> getNearbyChars(char c); isWord(String word);
package facebook;
import java.util.HashSet;
import java.util.Set;
/**
* The complexity of that algorithm is O(n^m), where:
* n - the length of a string.
* m - number of permutations.
*/
@alexrios
alexrios / docker_aliases.sh
Created May 20, 2016 13:36
docker aliases
# ~/.bash_aliases
# Kill all running containers.
alias dockerkillall='docker kill $(docker ps -q)'
# Delete all stopped containers.
alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
# Delete all untagged images.
alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'
package main
import (
"io/ioutil"
"log"
"net/http"
"time"
"io"
"flag"
"strconv"
@alexrios
alexrios / pixelserver.go
Created January 19, 2017 00:39
Serve a pixel tracking
package main
import (
"net/http"
"github.com/gorilla/handlers"
"os"
)
func main() {
http.ListenAndServe(":8080", handlers.CombinedLoggingHandler(os.Stdout, http.FileServer(http.Dir("/tmp/"))))