I hereby claim:
- I am pzelnip on github.
- I am pzelnip (https://keybase.io/pzelnip) on keybase.
- I have a public key ASDYIRO6gz6gvvLqd86UzD6JUybqgU9miTPjHfV0ZuzJIAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
# From https://www.linkedin.com/groups/25827/25827-6166706414627627011 | |
# "Today i did a simple test that you give a string to a function, and then the | |
# return output should count the letters sequencially; as following example: | |
# in: "aaaaabbbbccccccaaaaaaa" => out: "5a4b6c7a" | |
# | |
def func(input_string): | |
if not input_string: | |
return "" | |
if len(input_string) == 1: |
with a hat tip to Sublime Text 2 Shortcuts
⌘; | autocomplete |
⌘⌥B | instant replay |
⌘⌥E | search across all tabs |
<?xml version="1.0"?> | |
<!-- itemRenderers\events\EndEditEventPreventEdit.mxml --> | |
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:s="library://ns.adobe.com/flex/spark" | |
xmlns:mx="library://ns.adobe.com/flex/mx" | |
initialize="init()"> | |
<fx:Script> | |
<![CDATA[ | |
import mx.collections.ArrayCollection; |
<mx:DataGrid id="myGrid" | |
editable="true" | |
itemEditBeginning="disableEditing(event)"> | |
<!-- definition of columns & such here --> | |
</mx:DataGrid> |
private static File tmpDir; | |
@BeforeClass | |
public static void setUp() { | |
String dirname = UUID.randomUUID().toString().replace("-", ""); | |
tmpDir = new File(System.getProperty("java.io.tmpdir"), dirname); | |
if (!tmpDir.exists()) { | |
tmpDir.mkdir(); | |
} | |
} |
import sys | |
lines = [] | |
for i in range(1, len(sys.argv)): | |
lines.append("================================== START OF sys.argv%s==========================\n" % i) | |
with open(sys.argv[i]) as fobj: | |
for line in fobj: | |
lines.append(line.decode('utf-8')) | |
lines.append("================================== END OF sys.argv%s==========================\n" % i) |
import java.util.ArrayList; | |
import java.util.List; | |
public class TestTest implements Runnable { | |
public static void main(String [] args) throws InterruptedException { | |
List<Thread> threads = new ArrayList<Thread>(); | |
for (int x = 0; x < 10; x++) { |
from timeit import Timer | |
if __name__ == "__main__": | |
setup = 'x = list(range(100000))' | |
num_iter = 1000 | |
print(Timer('sum(1 for item in x if item % 2 == 0)', setup).timeit(num_iter)) | |
print(Timer('len([item for item in x if item % 2 == 0])', setup).timeit(num_iter)) | |
# prints (on my machine): | |
# 12.4215... |
''' | |
Example showing that isinstance checks are faster than doing a "it's better to ask for forgiveness than | |
permission approach. | |
''' | |
from timeit import Timer | |
# Silly timing code that can be ignored | |
def timeruns(runs, num_iterations = 100): | |
return [(label, Timer(cmd, imports).timeit(num_iterations)) |