Skip to content

Instantly share code, notes, and snippets.

View mosdragon's full-sized avatar

Muhammad Osama Sakhi mosdragon

View GitHub Profile
@mosdragon
mosdragon / fur_elise.ino
Last active August 29, 2015 13:55 — forked from spara/fur_elise.ino
Added RGB color coordination on pins 2,3, and 4, respectively. The lights glow at different intervals, creating combinations of all primary colors to enhance the music experience.
int r = 2;
int g = 3;
int b = 4;
void setup() {
pinMode(10, OUTPUT);
pinMode(r, OUTPUT);
pinMode(g, OUTPUT);
pinMode(b, OUTPUT);
@mosdragon
mosdragon / har_script.rb
Created March 23, 2014 02:30
Script to open HAR file passed as argument and display the fastest and slowest resources along with their respective loading times. Currently optimized to follow Object Oriented design principles.
# This version of har_script.rb adheres more strictly to
# OOP principles because it enables code reusability without code duplication
require 'json'
require 'open-uri'
# Helper Method nested_search goes through nested Hashes, finds message in
# desired key.
# @param obj, the hash
# @param key, the desired key to be found, nested within obj
# @globalVar, the global variable to be modified
@mosdragon
mosdragon / oop_bricktronics.ino
Last active October 23, 2015 22:03
Example of how to use C++ in Arduino to make wrapper classes around our motors and sensors for the robot. Also a demonstration of how we can use algorithms and data structures from the standard C++ libraries in our code
#include <Wire.h>
#include <Encoder.h>
#include <PID_v1.h>
#include <Adafruit_MCP23017.h>
#include <BricktronicsShield.h>
#include <BricktronicsMotor.h>
#include <BricktronicsLight.h>
#include <BricktronicsButton.h>
#include <BricktronicsUltrasonic.h>
@mosdragon
mosdragon / data_util.py
Last active March 7, 2016 20:07
A utility for taking discrete valued attributes and replacing with numerical values
import numpy as np
import pandas as pd
def clean_data(df, fill_method='ffill'):
'''
Takes in a pandas DataFrame and changes all string attributes and outputs
to integers. Returns the DataFrame and the mapping
fill_method can be:
- 'ffill': forward fill
- 'bfill': backward fill
@mosdragon
mosdragon / PokerTest.java
Last active September 28, 2018 19:56
Example of how to use ABAGAIL for Randomized Optimization of Neural Network Weights
package opt.test;
import func.nn.backprop.BackPropagationNetwork;
import func.nn.backprop.BackPropagationNetworkFactory;
import func.nn.backprop.BatchBackPropagationTrainer;
import func.nn.backprop.RPROPUpdateRule;
import opt.OptimizationAlgorithm;
import opt.RandomizedHillClimbing;
import opt.SimulatedAnnealing;
import opt.example.NeuralNetworkOptimizationProblem;