Skip to content

Instantly share code, notes, and snippets.

View k4rtik's full-sized avatar

Kartik Singhal k4rtik

View GitHub Profile
#!/usr/bin/env bash
# note: clang-tidy only accepts one file at a time, but we can run it
# parallel against disjoint collections at once.
find . \( -name \*.c -or -name \*.cpp -or -name \*.cc -or -name \*.h \) | xargs -n1 -P4 cleanup-tidy
# clang-format accepts multiple files during one run, but let's limit it to 12
# here so we (hopefully) avoid excessive memory usage.
find . \( -name \*.c -or -name \*.cpp -or -name \*.cc -or -name \*.h \) | xargs -n12 -P4 cleanup-format -i
#!/usr/bin/env bash
clang-format -style="{BasedOnStyle: llvm, IndentWidth: 4, AllowShortFunctionsOnASingleLine: None, KeepEmptyLinesAtTheStartOfBlocks: false}" "$@"
#!/usr/bin/env bash
clang-tidy \
-fix \
-fix-errors \
-header-filter=.* \
--checks=readability-braces-around-statements,misc-macro-parentheses \
$1 \
-- -I.
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
# We want to set the prefix to C-a. C-b is kind of awkward. C-a works well if
# CAPSLOCK is remapped to Ctrl.
set -g prefix C-a
unbind C-b
# We want to imitate WMs like i3 and allow tmux to reload its config in a few
# keystrokes.
bind r source-file ~/.tmux.conf
# We never want to use the mouse.
#!/usr/bin/env python2
from z3 import *
import math
# RAID-4 Non-Rotating Parity 0
class RealBlock(object):
def __init__(self, k, i, j, v):
self.k = k
self.i = i
@k4rtik
k4rtik / lift-scheduler.py
Created October 2, 2012 06:02
A simple lift scheduler program using nearest car approach
#!/usr/bin/python
# Assume there is a 50 storey building and it has 4 lifts. You have to write a
# scheduler program for the lifts. All the 4 lifts will be controlled by
# single program and Waiting time for peoples waiting for lift should be
# minimum.
#
# Using the Nearest Car approach described at http://www.quora.com/Is-there-any-public-elevator-scheduling-algorithm-standard
#
# Some assumptions include direction of lift at top floor will always be down,
# and on ground floor it will be up. More assumptions obvious from the code.
@k4rtik
k4rtik / Delete mass Drupal content
Created June 14, 2013 06:13
iMacros script for deleting a lot of spam content on a Drupal website.
VERSION BUILD=6011206 RECORDER=CR
URL GOTO=http://a.drupal.website/admin/content/node
'REFRESH
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:node-admin-content ATTR=* CONTENT=YES
TAG POS=1 TYPE=SELECT FORM=ID:node-admin-content ATTR=ID:edit-operation CONTENT=%delete
SET !TIMEOUT 2
SET !ERRORIGNORE YES
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:node-admin-content ATTR=ID:edit-submit-1
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:node-admin-content ATTR=ID:edit-submit
@k4rtik
k4rtik / dup2mod.go
Created November 27, 2015 04:27
One solution to Exercise 1.4 in GoPL
package main
import (
"bufio"
"fmt"
"os"
)
type LnFile struct {
Count int