Skip to content

Instantly share code, notes, and snippets.

View foxish's full-sized avatar
🎯
Focusing

Anirudh Ramanathan foxish

🎯
Focusing
View GitHub Profile
@foxish
foxish / increasing_seq
Created January 21, 2014 17:39
increasing_seq in Python3
count_max = count = 0
sum_max = sum = 0
prev_val = 0
with open("input.txt") as f:
for line in f:
num = int(line)
if num > prev_val:
count += 1
sum += num
@foxish
foxish / timer.cpp
Created February 6, 2014 12:47
Time any function using <ctime> or time.h
std::cout << "Start" << std::endl;
clock_t begin = clock();
//do something
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
std::cout << "Time = " << elapsed_secs << std::endl;
@foxish
foxish / profiled.txt
Created February 8, 2014 03:17
Profiling LRU cache, std::list
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
45.07 0.46 0.46 63437824 0.00 0.00 std::_List_const_iterator<int>::operator++()
22.78 0.69 0.23 32000 0.01 0.03 std::iterator_traits<std::_List_const_iterator<int> >::difference_type std::__distance<std::_List_const_iterator<int> >(std::_List_const_iterator<int>, std::_List_const_iterator<int>, std::input_iterator_tag)
18.32 0.87 0.19 63469824 0.00 0.00 std::_List_const_iterator<int>::operator!=(std::_List_const_iterator<int> const&) const
4.95 0.92 0.05 46462 0.00 0.00 void __gnu_cxx::new_allocator<std::_List_node<int> >::construct<std::_List_node<int>, int const&>(std::_List_node<int>*, int const&)
1.98 0.94 0.02 46462 0.00 0.00 std::_List_node<int>::_List_node<int const&>(int const&)
@foxish
foxish / 00commands.md
Last active August 29, 2015 13:56
libbz.so?

g++ -fPIC -shared lib.cpp -o lib.so -lbz2

  • generated lib.so

g++ -fPIC -shared bz.cpp lib.so -o liblib.so

  • generated liblib.so

g++ main.cpp liblib.so

  • generated a.out
@foxish
foxish / 1.html
Created February 26, 2014 12:31
Arun-boilerplate
<html>
<head>
<script src='http://code.jquery.com/jquery-latest.js'></script>
<script src='arun.js'></script>
<script type="text/javascript">
</script>
</head>
<body>
@foxish
foxish / response.txt
Created March 5, 2014 07:23
proxy chaining
fox@fox-VirtualBox ~/Desktop $ telnet
telnet> open 201.221.131.99 8080
Trying 201.221.131.99...
Connected to 201.221.131.99.
Escape character is '^]'.
CONNECT 31.28.23.219:8118 HTTP/1.1
HTTP/1.1 200 OK
@foxish
foxish / popcount.c
Last active August 29, 2015 13:57
popcount.c [SSE4]
#include <stdio.h>
int main(){
unsigned x, bout;
scanf("%d", &x);
bout = __builtin_popcount(x);
printf("%x, %x\n", x, bout);
__asm__("movl %1, %%eax; popcnt %%eax, %%eax; movl %%eax, %0;"
:"=r"(x) /* output */
@foxish
foxish / combinations.py
Created March 18, 2014 09:40
Combinations
#!/usr/bin/env python3
from pprint import pprint
comb_set = set()
def comb(li):
global comb_set
if len(li) > 0: comb_set.add(tuple(li))
for i in range(len(li)):
temp_li = list(li)
temp_li.pop(i)
@foxish
foxish / fan_ctrl.sh
Created July 21, 2014 19:45
Fan control: Dell
#sudo /home/anirudh/Installation/dellfand-0.9/dellfand 1 10 25 30 35
#sudo pkill dellfand
#sudo pkill dellfand
sudo modprobe i8k force=1
sudo i8kfan 2 2
@foxish
foxish / interesting.sh
Last active August 29, 2015 14:04
Interesting
inxi -Fxz #list several devices and drivers running on them