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
#lang racket
;; A solver for the following puzzle:
;; Given 5 integers a, b, c, d, and e,
;; find an expression that combines a, b, c, and d with arithmetic operations (+, -, *, and /) to get e.
(require srfi/1)
(define ops '(+ - * /))
@lkuper
lkuper / 17.scm
Last active October 27, 2019 17:17
;; This code is AWFUL and I'm sorry.
;; idea from http://stackoverflow.com/a/23718676/415518
;; This works after I added the `concat`!
(define permutations
(lambda (ls)
(cond
[(null? ls) '(())]
[(equal? (length ls) 1) `((,(car ls)))]
[(equal? (length ls) 2)
@conormm
conormm / r-to-python-data-wrangling-basics.md
Last active May 3, 2025 19:21
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

@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
@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 / 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
@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 / 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)
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();
@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