I hereby claim:
- I am xevix on github.
- I am xevix (https://keybase.io/xevix) on keybase.
- I have a public key ASDKzeeW4q_b8UXMKqF-posWghvBE63A41Msr3QCiHTrxwo
To claim this, I am signing this object:
fname = 'pwned-passwords-2.0.txt' | |
# Change me | |
# echo -n password | shasum -a 1 | awk '{print toupper($1)}' | |
password = '7C4A8D09CA3762AF61E59520943DC26494F8941B' | |
search = password | |
with open(fname) as f: | |
for line in f: | |
sha = line[:40] | |
if search == sha: |
I hereby claim:
To claim this, I am signing this object:
trait Folder { | |
type Item; | |
fn foldl1<F>(self, f: F) -> Option<Self::Item> | |
where | |
F: FnMut(Self::Item, &Self::Item) -> Self::Item; | |
} | |
impl<T: Clone> Folder for Vec<T> { | |
type Item = T; | |
fn foldl1<F>(self, mut f: F) -> Option<Self::Item> |
pub fn combine_all_option<T>(xs: &Vec<T>) -> Option<T> | |
where | |
T: Semigroup + Clone, | |
{ | |
match xs.first() { | |
Some(head) => { | |
// Dear lord this reads horribly | |
xs[1..].iter().fold(Some((*head).clone()), |acc, x| acc.combine(&Some((*x).clone()))) | |
} | |
_ => None |
def main(): | |
ary = ['I should never print'] | |
for elem in ary: | |
pass | |
other_ary = ['other'] | |
for other_elem in other_ary: | |
# "elem" hould not be defined here, but this works, because of Python's awful scoping rules |
def foo(a, b={}): | |
if a == 1: | |
b["oops"] = "boom" | |
return b | |
for i in xrange(3): | |
print "foo: {}".format(foo(i)) | |
# Output: |
def foo(bob, **kwargs): | |
pass | |
kwargs = {'bob': 'first param is also bob, when splatted, they clash...'} | |
foo('bar', **kwargs) # KABOOM! | |
# Traceback (most recent call last): | |
# File "<stdin>", line 1, in <module> | |
# TypeError: foo() got multiple values for keyword argument 'bob' |
struct Foo { | |
x: i32, | |
} | |
struct Bar<'a> { | |
foo: &'a Foo, | |
// Uncomment to disallow drop() | |
x: ::std::cell::RefCell<() /* Option<&'a Bar<'a>>*/>, | |
} |
import shapeless.syntax.std.tuple._ | |
import shapeless._, syntax.singleton._ | |
object ShapelessMain { | |
def main(args: Array[String]): Unit = { | |
val l = 23 :: "foo" :: true :: HNil | |
l(1) | |
val t = (23, "foo", true) | |
t(1) |
// From Shapeless `coproduct.scala` | |
sealed trait Animal | |
case class Cat(name: String, livesLeft: Int) extends Animal | |
case class Dog(name: String, bonesBuried: Int) extends Animal | |
case class Koala(name: String, leavesEaten: Int) extends Animal |