Skip to content

Instantly share code, notes, and snippets.

View hindol's full-sized avatar

Hindol hindol

View GitHub Profile
@hindol
hindol / hello-world.cpp
Created May 15, 2012 14:58
Hello world in C++
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
string name;
std::cin >> name;
std::cout << "Hello " << name << "!" << std::endl;
return 0;
@hindol
hindol / gitconfig
Created July 23, 2012 03:01
Git Aliases
[credential]
helper = cache --timeout=7200
[merge]
tool = meld
[diff]
tool = meld
[alias]
st = status
ci = commit
br = branch
@hindol
hindol / bitset.h
Created October 12, 2012 03:46
A BitSet class for C++03 and older
template <bool defaultState = false>
class BitSet
{
public:
BitSet(std::size_t size)
: size_(size), bits_((size_ + 7) / 8, defaultState ? 0xff : 0x0)
{
// Masks for each bit. Example,
//
// 7 6 5 4 3 2 1 0
@hindol
hindol / primesieve.h
Created October 12, 2012 03:49
Prime generator using Sieve of Eratothenes, uses a BitSet to save space
void AllPrimesTill(int32_t till, std::vector<int32_t>& primes)
{
BitSet<true> isPrime(till + 1);
isPrime.Reset(0);
isPrime.Reset(1);
int32_t cap = static_cast<int32_t>( std::sqrt(till) ) + 1;
primes.clear();
for (int32_t i = 2; i <= cap; ++i)
@hindol
hindol / merge_sort.h
Created October 24, 2012 12:41
Merge Sort (C++)
template <class FwdIt>
FwdIt Merge(
FwdIt first1, FwdIt last1,
FwdIt first2, FwdIt last2,
FwdIt result
)
{
while (true)
{
if (*first2 < *first1)
@hindol
hindol / array2d.h
Created November 12, 2012 03:40
2D Array Class
#include <cstddef>
#include <vector>
template <typename T>
class Array2D
{
public:
Array2D()
: height_(0), width_(0)
{}
@hindol
hindol / sudoers
Last active January 30, 2024 00:27
How to setup proxy for `sudo` environment. Tested for `Ubuntu` and `Linux Mint`.
# The following should be in `/etc/sudoers`. To edit `/etc/suoders` use the command `sudo visudo` in a terminal.
# *Do NOT attempt to modify the file directly*
Defaults env_reset
Defaults mail_badpass
Defaults env_keep+="http_proxy ftp_proxy all_proxy https_proxy no_proxy" # Add this line
...
@hindol
hindol / generate_plots.sh
Created August 30, 2013 10:07
Example on how to use GNUPlot to output high quality graphs
#!/usr/bin/env bash
INPUT_DIR="../50_5_5"
OUTPUT_DIR=".."
PARAMETERS=( "like-mindedness" "modularity" )
LABELS=( "Like-mindedness" "Modularity (Q)" )
for i in ${!PARAMETERS[*]}; do
gnuplot <<- EOF
@hindol
hindol / gn-mode.el
Created October 31, 2018 09:01
Google's `gn-mode.el` with Proper Package Headers
;;; gn-mode.el --- A major mode for editing gn files.
;; Copyright 2015 The Chromium Authors. All rights reserved.
;; Use of this source code is governed by a BSD-style license that can be
;; found in the LICENSE file.
;; Author: Elliot Glaysher <erg@chromium.org>
;; Version: 1.0
;; Created: April 03, 2015
;; Keywords: tools, gn, ninja, chromium
@hindol
hindol / clojure_in_15_minutes.md
Last active August 8, 2021 15:51
Clojure in 15 Minutes: A Crash-course

Clojure in 15 Minutes

Hello, Clojure!

(println "Hello, world!")
  • The same in Python,