Skip to content

Instantly share code, notes, and snippets.

pub struct OpenRadioContext<'a, 'b:'a> {
_context: PhantomData<&'b Context>,
usb_context: Box<Context>,
device_handle: DeviceHandle<'a>,
}
impl <'a, 'b> Drop for OpenRadioContext<'a, 'b> {
fn drop(&mut self) {
self.device_handle.release_interface(0).unwrap();
}
pub struct OpenRadioContext<'a> { // public struct
usb_context: Context, // private fields, safety depends on these not being accessed directly
device_handle: DeviceHandle<'a>,
}
... snip ...
impl <'a> OpenRadioContext<'a> {
fn open() -> OpenRadioContext<'a> {
import Data.Set as S
import Data.List as L
process :: String -> String
process input =
let lines' = lines input
sets = L.map S.fromList lines'
gemElements = L.foldl1 S.intersection sets
in show $ S.size gemElements
import Data.Set (fromList, intersection, size)
import Data.List (foldl1, map)
process :: String -> String
process = show . size . foldl1 intersection . map fromList . lines
main :: IO ()
main = interact process

Keybase proof

I hereby claim:

  • I am orclev on github.
  • I am orclev (https://keybase.io/orclev) on keybase.
  • I have a public key whose fingerprint is 7C7D 9E8A 33E5 AF57 ED0C 701B 53C2 D954 B35B 18BA

To claim this, I am signing this object:

@orclev
orclev / example.md
Last active October 12, 2023 16:57
Gitflow Examples

git flow usage

Start using git flow on a new repo or one you haven't used git flow on before

user@example ~/gitflow-example [master] $ git flow init
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master] 
Branch name for "next release" development: [develop] 

How to name your supporting branch prefixes?
@orclev
orclev / fizzbuzz.hs
Created November 30, 2012 20:36
FizzBuzz in Haskell
fbshow :: Int -> String
fbshow i | i `mod` 15 == 0 = "FizzBuzz"
| i `mod` 3 == 0 = "Fizz"
| i `mod` 5 == 0 = "Buzz"
| otherwise = show i
main :: IO ()
main = mapM_ (putStrLn . fbshow) [1 .. 100]
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@orclev
orclev / trie.py
Created February 29, 2012 04:17
Copied from vivekn / autocomplete / trie.py
"""
A fast data structure for searching strings with autocomplete support.
Copied this from https://github.com/vivekn/autocomplete/blob/master/trie.py
so I could embed it as a gist
"""
class Trie(object):
def __init__(self, value=None):
self.children = {}
self.value = value
@orclev
orclev / tst.py
Created February 29, 2012 04:09
Python TST implementation
# -*- coding: utf-8 -*-
# Copied from https://bitbucket.org/woadwarrior/trie/src/0ca6aab259b2/python/tst.py
_SENTINEL = ()
class TST(object) :
__slots__ = ('splitchar','l','m','r','v')
def __init__( self, ch=None ) :
self.splitchar = ch