Skip to content

Instantly share code, notes, and snippets.

View gnarula's full-sized avatar

Gaurav Narula gnarula

View GitHub Profile
@gnarula
gnarula / index.js
Created June 29, 2020 12:14
URLSearchParams react-native override
// Place this at the top of index.js in your react-native project
delete global.URLSearchParams;
delete global.URL;
const pollyfillGlobal = require('react-native/Libraries/Utilities/PolyfillFunctions').polyfillGlobal;
pollyfillGlobal('URL', () => require('whatwg-url').URL);
pollyfillGlobal('URLSearchParams', () => require('whatwg-url').URLSearchParams);
global.URL = require('whatwg-url').URL;
global.URLSearchParams = require('whatwg-url').URLSearchParams;
@gnarula
gnarula / stress_test.go
Created April 12, 2018 10:07
Stress Test for evoting
package service
import (
"fmt"
"testing"
"time"
"github.com/dedis/cothority"
"github.com/dedis/kyber"
"github.com/dedis/kyber/util/key"
@gnarula
gnarula / evotingTest.js
Created March 1, 2018 13:53
Evoting Test
const kyber = require('@dedis/kyber-js')
const cothority = require('@dedis/cothority')
const config = require('./config')
const hexToArrayBuffer = require('hex-to-array-buffer')
const mockVotes = () => {
const promises = []
for (let i = 0; i < voters.length; i++) {
const signature = generateSignature(voters[i])
// login
@gnarula
gnarula / tmux.conf
Last active September 14, 2018 10:01
Tmux configuration
unbind C-b
set -g prefix C-a
bind C-a send-prefix
set-option -ga terminal-overrides ",xterm-256color:Tc"
set-option -g default-terminal "xterm-256color"
# Start windows and panes at index 1
set -g base-index 1
setw -g pane-base-index 1
@gnarula
gnarula / init.vim
Last active July 9, 2020 13:25
Neovim config
let mapleader = ","
" Load vundle
set nocompatible
filetype off
call plug#begin()
" GUI enhancements
Plug 'itchyny/lightline.vim'
Plug 'machakann/vim-highlightedyank'
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function cover() {
$albumId = $this->getIdFromSlug($this->params('albumIdOrSlug'));
$album = $this->albumBusinessLayer->find($albumId, $this->userId);
// try to extract the first picture from the first track on the album
@gnarula
gnarula / bt.log
Created February 11, 2016 18:40
eiskaltdcpp-gtk segfault on search
Thread 19 (Thread 0x7fffb7fff700 (LWP 22175)):
#0 0x00007ffff57facf9 in syscall () from /usr/lib/libc.so.6
No symbol table info available.
#1 0x00007ffff7b5b87a in g_cond_wait_until () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#2 0x00007ffff7aeba69 in ?? () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#3 0x00007ffff7aec08b in g_async_queue_timeout_pop ()
from /usr/lib/libglib-2.0.so.0
No symbol table info available.
import java.util.*;
public class MergeSort {
public static void sort(Comparable[] arr) {
Comparable[] temp = new Comparable[arr.length];
sort(arr, temp, 0, arr.length - 1);
}
public static void sort(Comparable[] arr, Comparable[] aux, int lo, int hi) {
if(lo >= hi) {
from subprocess import check_output
for i in range(1,1000):
print(check_output(["java", "Sort"], universal_newlines=True, input="{0}\n".format(i)))