Skip to content

Instantly share code, notes, and snippets.

View nischalshrestha's full-sized avatar
👋
Haven't been open sourcing but will be back soon!

Nischal Shrestha nischalshrestha

👋
Haven't been open sourcing but will be back soon!
View GitHub Profile
@wch
wch / pairlist.R
Last active June 8, 2018 19:56
car, cdr, and push for pairlists in R
library(inline)
library(microbenchmark)
car <- cfunction(c(x = "pairlist"), '
if (x == R_NilValue)
return R_NilValue;
if (TYPEOF(x) != LISTSXP)
error("x must be a pairlist");
return CAR(x);
')
@amatellanes
amatellanes / parallel_fibonacci.py
Last active December 5, 2019 23:22
Fibonnaci series by using threading module in Python.
import threading
from Queue import Queue
fibo_dict = {}
shared_queue = Queue()
input_list = [3, 10, 5, 7]
queue_condition = threading.Condition()
@bllchmbrs
bllchmbrs / tfpdf.py
Last active December 29, 2021 14:10
TF IDF Explained in Python Along with Scikit-Learn Implementation
from __future__ import division
import string
import math
tokenize = lambda doc: doc.lower().split(" ")
document_0 = "China has a strong economy that is growing at a rapid pace. However politically it differs greatly from the US Economy."
document_1 = "At last, China seems serious about confronting an endemic problem: domestic violence and corruption."
document_2 = "Japan's prime minister, Shinzo Abe, is working towards healing the economic turmoil in his own country for his view on the future of his people."
document_3 = "Vladimir Putin is working hard to fix the economy in Russia as the Ruble has tumbled."
@dgrapov
dgrapov / dplyr_tutorial.Rmd
Created April 28, 2015 23:21
hands on with dplyr
---
title: "Hands-on with dplyr"
author: "Dmitry Grapov"
output:
html_document:
keep_md: yes
---
## Introduction
use std::fs::File;
use std::path::Path;
use std::io::BufReader;
use std::io::BufRead;
use std::collections::HashMap;
use std::io::stdin;
fn sort_str(s: &String) -> String {
let mut v: Vec<char> = s.chars().collect();
v.sort();
@xavriley
xavriley / ambient.rb
Created September 9, 2015 11:28
Ambient piece in Sonic Pi using multiple pentatonic scales
live_loop :foo do
with_fx :echo, mix: 0.3 do
sample :elec_tick if spread(2,7).tick
pattern1 = (knit :a3, 1, :d3, 1, :g3, 1)
pattern2 = (knit :a3, 1, :d3, 1, :g3, 1, :a0, 1)
pattern3 = (knit :a3, 1, :d3, 1, :g3, 1, :a5, 1)
structure = (knit pattern1, 128, pattern2, 32, pattern3, 32).tick(:structure)
@nesquena
nesquena / ItemClickSupport.java
Last active September 17, 2024 18:57
Click handling for RecyclerView
/*
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
USAGE:
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// do it
}
});
@xavriley
xavriley / gist:c1c0d255e6f2f40dcdb4
Created October 15, 2015 07:35 — forked from darinwilson/SonicPiDrumMachine
Sonic Pi Drum Machine
#########################################
## Sonic Pi Drum Machine
## coded by Darin Wilson
## changed by Xavier Riley
##
use_bpm 95
in_thread(name: :drum_machine) do
@BGR360
BGR360 / analyze_repo_languages.py
Created January 20, 2016 00:14
Analyzes a GitHub user's repositories to find their favorite programming languages.
"""
GitHub User Repository Language Analyzer
Created By: Ben Reeves
Date: January 8, 2015
Description:
This script uses the PyGithub library to access the Github API in order to perform some data analysis on a user's
repositories. Specifically, it will analyze all of the user's code and calculate the percentage of code written in
different programming languages.
"""
@xavriley
xavriley / bath_ruby_2016.rb
Created March 12, 2016 02:37
Final piece at BathRuby 2016
define :bo do |idx|
"Users/xriley/Dropbox/Public/sounds/barack/b#{idx}.wav"
end
use_bpm 125
live_loop :heartbeat do
sample :bd_tek, amp: 0, cutoff: (range 60, 90).mirror.tick
sleep 1
end