Skip to content

Instantly share code, notes, and snippets.

View rendon's full-sized avatar
🧑‍🔬
Trying new things out.

Rafael Rendón rendon

🧑‍🔬
Trying new things out.
View GitHub Profile
@rendon
rendon / D.cpp
Created September 8, 2016 15:13
Codeforces 368 div2#D
/* Copyright 20kSize Rafael Rendón Pablo <[email protected]> */
// region Template
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
const double kEps = 10e-8;
const int kMax = 100005;
const int kInf = 1 << 30;
const int kSize = 16;
@rendon
rendon / persistent_array.cpp
Created September 4, 2016 18:56
Persistent array implemented in C++ using balanced binary tree.
/* Copyright 2016 Rafael Rendón Pablo <[email protected]> */
// In this code array means persistent array and will be denoted by "array*".
#include <bits/stdc++.h>
using namespace std;
const int kMax = 10000;
// Node describes a node in the tree.
struct Node {
// Array* index.
int idx;
@rendon
rendon / max_diff_brute_force.cpp
Created June 14, 2016 13:27
Maximum difference between A[j] and A[i] such that j < i and A[j] < A[i]
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int n;
@rendon
rendon / konsole_tabs_style.css
Created June 6, 2016 12:26
Style sheet for Konsole's Tab bar
QTabBar {
background-color: #949191;
}
QTabBar::tab {
height: 20px;
border: none;
padding: 0;
}
@rendon
rendon / disjoint_set.py
Created May 22, 2016 16:53
Basic implementation of a DisjointSet in Python
class DisjointSet:
def __init__(self, size):
self.id = [i for i in range(size)]
self.size = [1 for i in range(size)]
def root(self, u):
if self.id[u] == u:
return u
return self.root(self.id[u])
@rendon
rendon / disjoint_set_test.py
Created May 22, 2016 16:53
Basic implementation of a DisjointSet in Python, tests.
import unittest
from disjoint_set import DisjointSet
class DisjointSetTest(unittest.TestCase):
def test_connectedness(self):
ds = DisjointSet(5)
self.assertFalse(ds.connected(0, 4))
ds.connect(0, 4)
self.assertTrue(ds.connected(0, 4))
@rendon
rendon / bridges.cpp
Last active May 22, 2016 23:56
Find bridges in graph (incomplete)
/* Copyright 2016 Rafael Rendón Pablo <[email protected]> */
// region Template
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
const double kEps = 10e-8;
const int kMax = 1000;
const int kInf = 1 << 30;
const int kRedEdge = 1;
@rendon
rendon / private.xml
Last active February 20, 2017 16:21
Karabiner configuration file for my keyboard on Mac OS
<?xml version="1.0"?>
<root>
<item>
<name>My settings</name>
<identifier>private.mysettings</identifier>
<autogen>__KeyToKey__ KeyCode::D, ModifierFlag::COMMAND_L, ConsumerKeyCode::MUSIC_NEXT</autogen>
<autogen>__KeyToKey__ KeyCode::S, ModifierFlag::COMMAND_L, ConsumerKeyCode::MUSIC_PREV</autogen>
<autogen>__KeyToKey__ KeyCode::P, ModifierFlag::COMMAND_L, ConsumerKeyCode::MUSIC_PLAY</autogen>
<autogen>__KeyToKey__ KeyCode::EQUAL, ModifierFlag::COMMAND_L, ConsumerKeyCode::VOLUME_UP</autogen>
<autogen>__KeyToKey__ KeyCode::MINUS, ModifierFlag::COMMAND_L, ConsumerKeyCode::VOLUME_DOWN</autogen>
@rendon
rendon / jquery_post.js
Created March 15, 2016 18:57
A quick reminder to POST using jQuery
$.post(
"http://myapi.com/v1/assets",
JSON.stringify({
name: name,
email: email
}),
function(data) {
alert(data.message);
},
"json"
@rendon
rendon / rugged_create_repo_and_add_file.rb
Created February 23, 2016 22:59
Rugged minimal example
require 'rugged'
dir = "/home/rendon/repos/snippet001/"
name = "README.md"
# For existing repositories
#repo = Rugged::Repository.new(dir)
repo = Rugged::Repository.init_at(dir)
File.open(File.join(dir, name), "w") do |f|