Skip to content

Instantly share code, notes, and snippets.

View iheanyi's full-sized avatar
🪐
Working on databases @planetscale

Iheanyi Ekechukwu iheanyi

🪐
Working on databases @planetscale
View GitHub Profile
int switchState = 0;
void setup() {
switchState = digitalRead(2);
}
void loop() {
pinMode(3, OUTPUT);
@iheanyi
iheanyi / Professor Sections Reset
Last active August 29, 2015 14:08
Counter Caches and HABTM
[5] pry(main)> Professor.reset_counters(4, :sections)
Professor Load (1.1ms) SELECT "professors".* FROM "professors" WHERE "professors"."id" = $1 LIMIT 1 [["id", 4]]
(0.4ms) SELECT COUNT(*) FROM "sections" WHERE "sections"."professor_id" = $1 [["professor_id", 4]]
(0.7ms) UPDATE "professors" SET "courses_count" = 12 WHERE "professors"."id" = 4
=> true
# Notice how it is updating the Courses Count, when I want this to be sections_count updated. :/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
Verifying that +iheanyi is my Bitcoin username. You can send me #bitcoin here: https://onename.io/iheanyi

Keybase proof

I hereby claim:

  • I am iheanyi on github.
  • I am iheanyi (https://keybase.io/iheanyi) on keybase.
  • I have a public key whose fingerprint is CDF6 00AF E53F 0CD3 D00D FFC1 569F 4E58 2B88 6B2E

To claim this, I am signing this object:

from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@iheanyi
iheanyi / Makefile
Created August 21, 2013 16:07
Makefile automation script, makes making makefiles a breeze
cpps = $(wildcard *.cpp */*.cpp)
objs = $(cpps:.cpp=.o)
deps = $(cpps:.cpp=.d)
CPPFLAGS = -I include/ -g -std=c++11 -Wall -Wextra -pedantic -Werror
all: executable
%.d: %.cpp %.o Makefile
g++ $(CPPFLAGS) -MM -MT $(<:.cpp=.o) $< -o $@
@iheanyi
iheanyi / animation.css
Created July 8, 2013 02:35
Flying animation snippet for Jeff, this is the CSS
/* Preferably make this your container */
.target {
-webkit-animation: fly-in-from-left .5s .5s ease both;
-moz-animation: fly-in-from-left .5s 1s ease both;
-o-animation: fly-in-from-left .5s 1s ease both;
animation: fly-in-from-left .5s .5s ease both;
-webkit-transform-origin: top left;
transform-origin:top left;
}
@iheanyi
iheanyi / NowArrayAdapter.java
Last active February 10, 2019 17:32
Google Now Cards Layout XML. list_item.xml can be customized to your heart's content . . . Also, you can implement the following with DragSortListView for swiping to delete, reordering, and whatnot.
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
@iheanyi
iheanyi / update_db.py
Created December 6, 2012 16:39
update_db.py command, not working
from django.db import models
from django.core.management.base import BaseCommand, CommandError
from IrishSchedule.models import Department, Course, Section
import mechanize
import requests
from BeautifulSoup import BeautifulSoup
#import os
#os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
class Command(BaseCommand):