Skip to content

Instantly share code, notes, and snippets.

View zmallen's full-sized avatar

Zack Allen zmallen

View GitHub Profile
@zmallen
zmallen / Loader.scala
Created September 3, 2013 19:14
future
val f: Future[Array[String]] = future {
t.Scrape()
}
f onSuccess {
case arr => {
println("Scrape complete " + arr.length)
}
}
@zmallen
zmallen / gist:7089395
Created October 21, 2013 19:22
logLua function
int logLua(lua_State *lua)
{
// get # of arguments from the pdnslog() lua stack
// if it is 1, then the old pdnslog(msg) is used, which we keep for posterity and to prevent lua scripts from breaking
// if it is 2, then we process it as pdnslog(msg, urgencylevel) for more granular logging
int argc = lua_gettop(lua);
if(argc == 1) {
string message=lua_tostring(lua, 1);
theL()<<Logger::Error<<"From Lua script: "<<message<<endl;
} else if(argc == 2) {
int logLua(lua_State *lua)
{
// enum Urgency {All=99999,NTLog=12345,Alert=LOG_ALERT, Critical=LOG_CRIT, Error=LOG_ERR, Warning=LOG_WARNING,
// Notice=LOG_NOTICE,Info=LOG_INFO, Debug=LOG_DEBUG, None=-1};
// get # of arguments from the pdnslog() lua stack
// if it is 1, then the old pdnslog(msg) is used, which we keep for posterity and to prevent lua scripts from breaking
// if it is 2, then we process it as pdnslog(msg, urgencylevel) for more granular logging
int argc = lua_gettop(lua);
if(argc == 1) {
string message=lua_tostring(lua, 1);
from Crypto.Cipher import AES
import os, struct, sys, httplib, urllib
from sys import platform as _platform
import subprocess as sub
class lolCrypt:
def __init__(self, key, iv):
self.key = key
self.iv = iv
self.cryptor = AES.new(self.key, AES.MODE_CBC, self.iv)
### Keybase proof
I hereby claim:
* I am zmallen on github.
* I am techy (https://keybase.io/techy) on keybase.
* I have a public key whose fingerprint is 8E36 C455 CB01 93A0 9BC4 F137 6F14 907A 4B66 7C2C
To claim this, I am signing this object:
@zmallen
zmallen / strace
Created September 25, 2014 16:56
write(2, "*BUG* File: [compress.c] Line: ["..., 36) = 36
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(13317, 13317, SIGABRT) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=13317, si_uid=11176} ---
rt_sigreturn() = 0
rt_sigaction(SIGABRT, {SIG_DFL, ~[], SA_RESTORER, 0x7f3191151c30}, NULL, 8) = 0
tgkill(13317, 13317, SIGABRT) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=13317, si_uid=11176} ---
+++ killed by SIGABRT (core dumped) +++
<div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="addRaceModal">Add a Race</h4>
</div>
<div class="modal-body">
<label for="sel1">Select season:</label>
<select class="form-control" id="sel1">
<option>Spring</option>

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

private int determinant(int row, int col, int size) {
int sum = 0;
if(size == 1) {
return this.data[0][0];
}
else if (size == 2) {
return (this.data[row][col] * this.data[row+1][col+1]) - (this.data[row][col+1] * this.data[row+1][col]);
} else {
return determinant(row+1,col+1,size);
}
java.lang.RuntimeException: java.io.NotSerializableException: com.fasterxml.jackson.module.paranamer.shaded.CachingParanamer
at backtype.storm.serialization.DefaultSerializationDelegate.serialize(DefaultSerializationDelegate.java:43) ~[storm-core-0.9.5.jar:0.9.5]
at backtype.storm.utils.Utils.serialize(Utils.java:85) ~[storm-core-0.9.5.jar:0.9.5]
at backtype.storm.topology.TopologyBuilder.createTopology(TopologyBuilder.java:106) ~[storm-core-0.9.5.jar:0.9.5]
at fastly.storm.topology.FastlyTopology$.main(Topology.scala:21) ~[classes/:na]
at fastly.storm.topology.FastlyTopology.main(Topology.scala) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]