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 java.lang.reflect.Constructor; | |
import java.lang.reflect.Method; | |
import java.lang.reflect.Field; | |
import sun.misc.Unsafe; | |
class S { | |
private void privatePrintS () { System.out.println("This is in S."); }; | |
public void publicPrintS () { System.out.println("This is in S."); }; | |
} |
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
class SegmentTree: | |
def __init__(s_): | |
s_.segtree=[] | |
s_.lazytree=[] | |
s_.treelayer=0 | |
s_.capacity=0 | |
s_.datalength=0 | |
s_.compare=max | |
s_.firstleaf=0 | |
s_.numleafs=0 # alias to firstleaf |
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
#include <iostream> | |
#include <cstdlib> | |
#include <iomanip> | |
#include <queue> | |
#include <vector> | |
#include <algorithm> | |
#include <unordered_map> | |
#include <string> | |
using namespace std; |
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
#include <iostream> | |
#include <cstdlib> | |
#include <iomanip> | |
#include <queue> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int LIMIT = 1e5; |
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
#include <iostream> | |
#include <string> | |
#include <utility> | |
using namespace std; | |
void ___m1(string* s, int lo, int hi){ | |
cout << "Let's sort! [" << lo << "," << hi << "] "; | |
for(int i=0;i<lo;i++) cout << (*s)[i]; | |
cout << "|"; |
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
class Sorter: | |
def __init__(self,data): | |
self.orig = data.copy() | |
self.data = data | |
def do_qsort(self): | |
print("Original data",self.orig) | |
self.run_qsort(0,len(self.data)-1) | |
print("Sorted data ",self.data) |
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/bash | |
if [[ $# -eq 1 ]] ;then | |
case $1 in | |
-c) option="camel" ;; | |
-p) option="pascal" ;; | |
*) echo "This option $1 is not supported."; exit 1 ;; | |
esac | |
else | |
echo "Give an option -c (Camel case) or -p (Pascal case)." |
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 socket | |
import time | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
s.connect(('xxxxxxxx', 8080)) | |
s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) | |
s.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, 35) | |
s.send(b'GET / HTTP/1.1\r\nHost: localhost') | |
data = s.recv(1024) | |
print(data) |
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 socket | |
QUEUELIMIT = 5 | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
s.bind(('',8080)) | |
s.listen(QUEUELIMIT) | |
s.setsockopt(socket.SOL_TCP, socket.TCP_DEFER_ACCEPT, 1) | |
while True: | |
conn, addr = s.accept() |
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 socket | |
import time | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
s.connect(('127.0.0.1', 8080)) | |
time.sleep(1) | |
s.send(b'GET / HTTP/1.1\r\nHost: localhost') | |
data = s.recv(1024) | |
print(data) |
NewerOlder