This file contains hidden or 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
class TreeNode: | |
def __init__(self, value, left, right): | |
self.value = value | |
self.left = left | |
self.right = right | |
class BinarySearchTree: | |
def __init__(self): |
This file contains hidden or 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
class ListNode: | |
def __init__(self, value, next): | |
self.value = value | |
self.next = next | |
class LinkedList: | |
def __init__(self): | |
self.head = None |
This file contains hidden or 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 static boolean isElementPresentSorted(int[] m, int elem) { | |
// BINARY SEARCH | |
int first = 0, last = m.length - 1; | |
while (first <= last) { | |
int middle = first + (last - first) / 2; | |
if (m[middle] == elem) { | |
return true; | |
} else if (m[middle] < elem) { | |
first = middle + 1; | |
} else { |
This file contains hidden or 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
/* | |
* Calculate the ADLER32 of a sequence of bytes by chunks, allowing to | |
* use threads to speed up the calculations. | |
* | |
* By Alejandro Santos <[email protected]> | |
*/ | |
#include <stdio.h> |
This file contains hidden or 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
/* | |
* List the files inside a ROOT file and print the specific histogram or object. | |
* | |
* By Alejandro Santos | |
* | |
* Build with: g++ dump_root_hist.cpp -Wall -g $(root-config --cflags --glibs) | |
* | |
*/ |
This file contains hidden or 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
#include <boost/intrusive_ptr.hpp> | |
#include <boost/smart_ptr/intrusive_ref_counter.hpp> | |
// boost intrusive pointer example | |
// change boost::thread_unsafe_counter to boost::thread_safe_counter for a thread safe version | |
// you shouldn't be passing smart pointer among threads anyway... | |
class Object : private boost::noncopyable, public boost::intrusive_ref_counter<Object, boost::thread_unsafe_counter> { | |
protected: |
This file contains hidden or 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
[ 2525.145364] IPv6: ADDRCONF(NETDEV_CHANGE): em1: link becomes ready | |
[ 2589.973799] skbuff: skb_under_panic: text:ffffffffa0a36810 len:20 put:15 head:ffff880223282a00 data:ffff8802232829fe tail:0x12 end:0xc0 dev:<NULL> | |
[ 2589.973854] ------------[ cut here ]------------ | |
[ 2589.976829] kernel BUG at /build/linux-RYwSFv/linux-3.16.7-ckt20/net/core/skbuff.c:100! | |
[ 2589.980700] invalid opcode: 0000 [#3] SMP | |
[ 2589.984244] Modules linked in: ax25 tun ctr ccm bnep rtsx_usb_ms memstick rtsx_usb_sdmmc rtsx_usb openafs(PO) nfsd auth_rpcgss oid_registry nfs_acl nfs lockd fscache sunrpc snd_hda_codec_hdmi snd_hda_codec_conexant snd_hda_codec_generic uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_core v4l2_common videodev media ecb arc4 brcmsmac cordic brcmutil btusb bluetooth b43 6lowpan_iphc mac80211 cfg80211 ssb x86_pkg_temp_thermal intel_powerclamp mmc_core rng_core intel_rapl pcmcia coretemp pcmcia_core iTCO_wdt iTCO_vendor_support kvm_intel kvm crc32_pclmul joydev cryptd psmouse evdev i2c_i801 serio_raw pc |
This file contains hidden or 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 python3 | |
# coding: utf-8 | |
import os | |
import pprint | |
import sys | |
def tokenize_file(file_name): | |
output = [] | |
with open(file_name, 'r', encoding="utf-8") as f: |
This file contains hidden or 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 | |
""" | |
http://en.wikipedia.org/wiki/Bin_packing_problem | |
""" | |
import os, sys, random | |
def empaquetar_ordenado(E, L, Ordenar=True): | |
if Ordenar: |
This file contains hidden or 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 java.util.Date; | |
import com.espertech.esper.client.Configuration; | |
import com.espertech.esper.client.EPAdministrator; | |
import com.espertech.esper.client.EPRuntime; | |
import com.espertech.esper.client.EPServiceProvider; | |
import com.espertech.esper.client.EPServiceProviderManager; | |
import com.espertech.esper.client.EventBean; | |
import com.espertech.esper.client.UpdateListener; | |
import com.espertech.esper.client.time.CurrentTimeEvent; |
NewerOlder