This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import random | |
import string | |
from optparse import OptionParser | |
class GenPassword: | |
_CHARSET = string.letters + string.digits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[esammer@xxxxx ~]$ ls -al /mnt/ | |
ls: cannot access /mnt/foo: Permission denied | |
total 8 | |
drwxr-xr-x. 3 root root 4096 Mar 20 17:48 . | |
dr-xr-xr-x. 23 root root 4096 Apr 17 14:09 .. | |
d?????????? ? ? ? ? ? foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
def fair_share(scheduables, totalCapacity): | |
print "demand:%s totalCapacity:%s" % (scheduables, totalCapacity) | |
totalDemand = reduce(lambda a, b: int(a) + int(b), [x['demand'] for x in scheduables]) | |
cap = min(totalDemand, totalCapacity) | |
weightSlotRatio = 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
def load_passwd(path): | |
lookup = { } | |
f = file(path) | |
for line in f: | |
line = line.rstrip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AvroProjectionMapFn extends MapFn<Record, Record> { | |
private static final long serialVersionUID = 1L; | |
private List<String> fieldNames; | |
private Schema sourceSchema; | |
private Schema projectionSchema; | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ${enclosing_type} ${name:field}(${type:elemType(name)} ${name}) { | |
this.${name} = ${name}; | |
return this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wire this up to an eclipse template called slf4j_logger and never type it again. | |
private static final Logger logger = LoggerFactory.getLogger(${enclosing_type}.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
} catch (NullPointerException e) { | |
throw npe(e, " of "+schema.getFullName()); | |
} | |
} | |
/** Helper method for adding a message to an NPE. */ | |
protected NullPointerException npe(NullPointerException e, String s) { | |
NullPointerException result = new NullPointerException(e.getMessage()+s); | |
result.initCause(e.getCause() == null ? e : e.getCause()); | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* A simple example of user demographic dataset generation in scala. | |
* | |
* This highlights the following scala bits: | |
* - Java integration | |
* - Annotations | |
* - Tail recursion optimization | |
* - Enums | |
* - Vals vs. vars | |
* - Working with singleton objects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> :silent | |
Switched off result printing. | |
scala> class Bad { | |
| var toStringCount: Int = 0 | |
| override def toString(): String = { toStringCount += 1 ; super.toString() } | |
| } | |
scala> val b = new Bad |
OlderNewer