Skip to content

Instantly share code, notes, and snippets.

@syst3mw0rm
syst3mw0rm / sources.list
Last active May 8, 2019 02:39
Ubuntu 13.10 sources.list
#############################################################
################### OFFICIAL UBUNTU REPOS ###################
#############################################################
###### Ubuntu Main Repos
deb http://in.archive.ubuntu.com/ubuntu/ saucy main restricted universe
###### Ubuntu Update Repos
deb http://in.archive.ubuntu.com/ubuntu/ saucy-security main restricted universe
deb http://in.archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe
#include<iostream>
#include<vector>
#include<cstdio>
#include<set>
#include<map>
#include<algorithm>
#include<string.h>
#include<string>
#include<cassert>
#include<stack>
N = int(raw_input())
pro = 1
num = []
for i in xrange(N):
d = int(raw_input())
pro = pro * d
num.append(d)
for i in xrange(N):
print "%d" % (pro / num[i])
@syst3mw0rm
syst3mw0rm / gist:7588050
Created November 21, 2013 19:31
move newest file, print file count
import os, glob, time, operator
def get_oldest_file(files, _invert=False):
gt = operator.lt if _invert else operator.gt
# Check for empty list.
if not files:
return None
# Raw epoch distance.
now = time.time()
public List<Tweet> fetchOlderFeeds(Long user_id, Long tweet_id) {
List<Tweet> tweetList = jdbcTemplate.query("select t.* from tweet t INNER JOIN following f ON (f.user_id2 = t.user_id) " +
"WHERE t.tweet_id < ? AND f.user_id1 = ? " +
"UNION ALL SELECT * FROM tweet t WHERE t.user_id=? AND t.tweet_id < ? " +
"ORDER BY tweet_id desc limit 15",
new Object[]{tweet_id, user_id, user_id, tweet_id}, new BeanPropertyRowMapper<>(Tweet.class));
return tweetList;
@syst3mw0rm
syst3mw0rm / gist:6299407
Created August 21, 2013 19:59
user news feed
explain Select * from tweet where tweet_id < 9999999999999 and (user_id in (select user_id2 from following where user_id1 = 1) or user_id = 1 ) order by tweet_id desc limit 15;
public List<Tweet> fetchFeedsOfUser(Long user_id,int tweet_id) {
return jdbcTemplate.query("Select * from tweet where tweet_id < ? and (user_id in (select user_id2 from following where user_id1 = ?) or user_id = ? ) order by timestamp desc limit 15",
new Object[]{tweet_id,user_id,user_id}, new BeanPropertyRowMapper<>(Tweet.class));
}
@syst3mw0rm
syst3mw0rm / gist:5469526
Created April 26, 2013 18:53
puzzle1 viennaCL
#include <iostream>
#include <vector>
#include "viennacl/vector.hpp"
#include "benchmark-utils.hpp"
#define BENCHMARK_VECTOR_SIZE 1000
#define BENCHMARK_RUNS 10
int main() {
<?php
// h4x0r's ultimate encryption algorithm
// I put the string to be encrypted here
$str = 'aaaaaaaaaaaaaaaaaa';
// I convert the string to ASCII
// I generate a random key in between 10 and the maximum value of the ASCII's
// So the key is different everytime B)
import re
import socket,time,zlib,sys
from struct import pack
sk = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sk.connect(("106.187.35.165",8080))
buff = sk.recv(1024)
print 'Received', repr(buff)