Skip to content

Instantly share code, notes, and snippets.

@aajjbb
aajjbb / gist:52ccbfa1e53700944aea
Created January 22, 2015 16:50
this is how to use your mouse/touchpad to control volume in awesome-wm
volumewidget:buttons(awful.util.table.join(
awful.button({ }, 4, function () awful.util.spawn("amixer set Master 2%+") end),
awful.button({ }, 5, function () awful.util.spawn("amixer set Master 2%-") end)
))
@aajjbb
aajjbb / sort.c
Created November 22, 2014 02:43
A few wrap of sorting algorithms to remember a little of pointer arithmetics in C
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define MAXL 15
#define MAX_VALUE 10;
int* generate(void) {
int i;
#include <bits/stdc++.h>
template<typename T> T gcd(T a, T b) {
if(!b) return a;
return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
return a * b / gcd(a, b);
}
#include <bits/stdc++.h>
template<typename T> T gcd(T a, T b) {
if(!b) return a;
return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
return a * b / gcd(a, b);
}
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
typedef unsigned uint;
class PackingBallsDiv2 {
public:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <string.h>
#define ll long long
#define MAXN 100002
class LittleElephantAndIntervalsDiv2 {
public:
int getNumber(int, vector <int>, vector <int>);
};
int LittleElephantAndIntervalsDiv2::getNumber(int M, vector <int> L, vector <int> R) {
//0 - W, 1 - B
vector<int> base(M, 0);
queue<pair<vector<int>, int> > q;
class LittleElephantAndBallsAgain {
public:
int getNumber(string);
};
set<string> memo;
map<string, int> dp;
int func(string s) {
if (memo.count(s)) {
@aajjbb
aajjbb / merge.py
Created October 16, 2013 23:41
Python implementation of merge sort
class MergeSort(object):
def __init__(self):
pass
def merge(self, left, right):
ans = []
while left and right:
if left[0] < right[0]:
ans.append(left.pop(0))
else:
struct LISNumberDivTwo {
int calculate(vector <int> seq) {
int i, j, ans = 0, N = seq.size();
for (i = 0; i < N; i++) {
j = i + 1;
priority_queue<int> q; q.push(seq[i]);
while (j < N && seq[j] > q.top()) {
q.push(seq[j]); j += 1;
}