Skip to content

Instantly share code, notes, and snippets.

View ludflu's full-sized avatar
🎯
Focusing

Jim Snavely ludflu

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ludflu on github.
  • I am ludflu (https://keybase.io/ludflu) on keybase.
  • I have a public key whose fingerprint is CB64 897A 29BD ED98 BC18 3383 7E60 514A 57EC B7DC

To claim this, I am signing this object:

window.rjm.app.rjmNgDirectives.directive "validateBigCommerce", [
() ->
require: 'ngModel'
restrict: 'A'
link: (scope, ele, attrs, controller) ->
# var initializing used to prevent error messages from
# showing right away.
initializing = true
scope.$watch attrs.ngModel, (value) ->
@ludflu
ludflu / pycallback
Created July 9, 2014 15:55
python -> C++ callback
#this is the variable that will hold a reference to the python function
PyObject *py_callback;
#the following function will invoked from python to populate the call back reference
PyObject *set_py_callback(PyObject *callable)
{
py_callback = callable; /* Remember new callback */
return Py_None;
}
...
window :: Int -> [a] -> [[a]]
--base case
window sz [] = []
-- the "@" sign lets you alias the destructed variable as in "whole@(head:tail)"
-- "take N list" gives you the first N elements of list
window sz lst@(h:tl)= [take sz lst] ++ window sz tl
main = do
let seq = window 2 [1..25]
@ludflu
ludflu / ratings.md
Last active August 29, 2015 14:11
how to get great ratings blog post

Getting Great Ratings

Building a great app is hard, and so is building an audience. The exposure you get in the app store is critical, so developers need to make the most of it. Many apps ask their users to leave a review, in hopes of boosting their ranking in the app store. But pitfalls abound.

Recently the creators of Circa, the popular news app, shared some insights on how they achieved a stellar 5-star rating from 90% of the users who chose to leave a review.

There are several techniques that Circa used. We're going to breakdown two of their reccommendations and show how you can use Artisan tools to handle the drudgework, allowing you to implement their strategy quickly and easily.

Asking at the right time

Instead of asking any random user for a rating, smart developers can use analytics to send their request to the people most likely to give great ratings. Frequent users are your biggest fans, and its a good

@ludflu
ludflu / scaldingtest.scala
Last active August 29, 2015 14:26
scalding test
import com.twitter.scalding._
import com.twitter.scalding.ReplImplicits._
import com.twitter.scalding.ReplImplicitContext._
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
case class LatLonRecord(date : DateTime, msidn : String, lat : Double, lon : Double, cellname : String)
implicit def stringToDateTime(dateStr: String) : DateTime =
DateTime.parse(dateStr, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.S"))
@ludflu
ludflu / jarjarblinks.py
Created August 13, 2015 19:26
python script for rooting out unused jars
@ludflu
ludflu / lc.hs
Last active September 18, 2015 01:28
import System.Environment
contains :: String -> Int
contains s = if (elem 'e' s) then 1 else 0
main = do
args <- getArgs
content <- readFile (args !! 0)
let ws = concatMap words $ lines content
matchCount = map contains ws in
@ludflu
ludflu / whyfp.md
Last active August 29, 2016 02:54
why functional programming is important (to me)

#Why Functional Programming Matters (to me)

This is my response to being asked not to use functional programming techniques.

###What I mean by "Functional Programming" Different people mean different things by "Functional Programming". Here's what it means to me:

  • Functions are first class, fundamental atoms of software, and proper functional programming languages allows passing functions as arguments, assigning them to variables, and composing them together to form new functions.
  • Strong Static Typing prevents many common programming errors automatically.
  • Null pointer dereferences can by virtually eliminated using Optional/Option/Maybe/Either data types to explicitly represent empty or error conditions.
  • Together with sum types, strongly typed languages can automatically perform local totality checking, informing the programmer when a logical branch is not handled.
def parseInt1( s : String) : Option[Int] = {
try {
Some(s.toInt)
} catch {
case _ : Throwable => None
}
}
def parseInt2(s: String): Option[Int] = {
Try(s.toInt) match {