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
/* | |
* | |
* * Licensed to the Apache Software Foundation (ASF) under one | |
* * or more contributor license agreements. See the NOTICE file | |
* * distributed with this work for additional information | |
* * regarding copyright ownership. The ASF licenses this file | |
* * to you under the Apache License, Version 2.0 (the | |
* * "License"); you may not use this file except in compliance | |
* * with the License. You may obtain a copy of the License at | |
* * |
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
#!/bin/sh | |
# | |
# Originally part of vpnc source code: | |
# © 2005-2012 Maurice Massar, Jörg Mayer, Antonio Borneo et al. | |
# © 2009-2012 David Woodhouse <[email protected]> | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. |
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
trait BeforeAndAfterEach { def beforeEach(): Unit = () } | |
trait ResetSystemProperties extends BeforeAndAfterEach { override def beforeEach(): Unit = println("reset") } | |
class A extends BeforeAndAfterEach with ResetSystemProperties { override def beforeEach() { println("test") } } | |
class B extends BeforeAndAfterEach with ResetSystemProperties { override def beforeEach() { super.beforeEach(); println("test") } } | |
scala> (new A()).beforeEach | |
test | |
scala> (new B()).beforeEach | |
reset |
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 class to experiment with your JVM's garbage collector | |
* and memory sizes for various data types. | |
* | |
* @author <a href="mailto:[email protected]">Vladimir Roubtsov</a> | |
*/ | |
public class Sizeof | |
{ | |
public static void main (String [] args) throws Exception |
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
case class BitMap(val n: Int) { | |
private val bytes = Array.fill(n / 8 + 1)(0.toByte) | |
def setBit(i: Int) { | |
bytes(i / 8) = (bytes(i / 8) | (1 << (i & 7))).toByte | |
} | |
def unSetBit(i: Int) { | |
bytes(i / 8) = (bytes(i / 8) & ~(1 << (i & 7))).toByte | |
} |
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
import scala.collection.immutable.NumericRange | |
import scala.collection.mutable.ArrayBuffer | |
import scala.reflect.ClassTag | |
private object ParallelCollectionRDD { | |
/** | |
* Slice a collection into numSlices sub-collections. One extra thing we do here is to treat Range | |
* collections specially, encoding the slices as other Ranges to minimize memory cost. This makes | |
* it efficient to run Spark over RDDs representing large sets of numbers. And if the collection | |
* is an inclusive Range, we use inclusive range for the last slice. |
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 int whileLoop(int); | |
descriptor: (I)I | |
flags: ACC_PUBLIC | |
Code: | |
stack=2, locals=3, args_size=2 | |
0: iconst_0 | |
1: istore_2 | |
2: iload_2 | |
3: iload_1 | |
4: if_icmpge 16 |
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
#coding:utf-8 | |
import sys,struct,socket,array,datetime | |
def ip2str(ip): | |
return str(ip>>24)+'.'+str((ip>>16)&0xffL)+'.' \ | |
+str((ip>>8)&0xffL)+'.'+str(ip&0xffL) | |
def str2ip(s): | |
(ip,) = struct.unpack('!I',socket.inet_aton(s)) | |
return ((ip>>24)&0xffL)|((ip&0xffL)<<24) \ |
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/python2 | |
#coding=utf-8 | |
import os | |
import urllib2 | |
import zipfile | |
import zlib | |
from urlparse import urlparse | |
from time import strftime,localtime | |
def initsites(filename): |
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 sys | |
import socket | |
data = """ | |
100.200.208.12-100.200.208.46 : /xxx/rack_1 | |
""" | |
def ip_integer_from_string(s): | |
return reduce(lambda a,b: a<<8 | b, map(int, s.split("."))) |
NewerOlder