Skip to content

Instantly share code, notes, and snippets.

@Davidslv
Davidslv / sound_maker.js
Created October 21, 2022 22:59
Playing Sound with Javascript
class SoundMaker {
constructor() {
this.context = new AudioContext();
this.oscillator = new Oscillator(this.context);
this.gain = this.context.createGain();
this.volume = new Volume(this.context, this.gain);
}
start() {
this.oscillator.connect(this.gain);
@Davidslv
Davidslv / square-canvas.html
Created December 17, 2021 09:21
Experimenting with Canvas
<!DOCTYPE html>
<html lang="en" dir="ltr">
<body>
<canvas id="canvas" width="600" height="600"></canvas>
<script type="text/javascript">
let canvas = document.querySelector('canvas');
let context = canvas.getContext('2d');
context.fillStyle = 'blue';
# gem instal rumouse
require 'rumouse'
x, y = 1527, 612
mouse = RuMouse.new
mouse.move x, y
0.upto(500) do
sleep 0.02
print '.'
@Davidslv
Davidslv / cleanup
Last active May 1, 2019 10:35
Delete local branches - except master, staging & production
git fetch --prune
git branch --merged | grep -v '\*\|master\|staging|production' | xargs -n 1 git branch -d
// Uncompressed version of
// https://gist.github.com/munificent/b1bcd969063da3e6c298be070a22b604
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#include <stdbool.h> // 2008-2019
const int HEIGHT = 40;
const int WIDTH = 80;
(function() {
"use strict";
window.GOVUK = window.GOVUK || {};
var $ = window.jQuery;
function BrowseColumns(options){
if(options.$el.length === 0) return;
if($(window).width() < 640) return; // don't ajax navigation on mobile
this.$el = options.$el;
@Davidslv
Davidslv / unused_methods.rb
Last active December 1, 2016 09:35
ruby unused methods
#!/usr/bin/env ruby
require 'optparse'
module CLI
extend self
PATHS_TO_CHECK = %w(app bin config engines lib script)
EXTENSIONS_TO_CHECK_FOR_DEFINITIONS = %w(.rb .rake)
EXTENSIONS_TO_CHECK_FOR_USAGE = EXTENSIONS_TO_CHECK_FOR_DEFINITIONS + %w(.yml .yaml .erb)
@Davidslv
Davidslv / find-unused-ruby-methods.sh
Last active December 1, 2016 09:18 — forked from joelittlejohn/find-unused-clj.sh
find unused code..
#!/bin/bash
for f in $(egrep -o -R "def?-? [^ ]*" * --include '*.rb' | cut -d \ -f 2 | sort | uniq); do
echo $f $(grep -R --include '*.rb' -- "$f" * | wc -l);
done | grep " 1$"
---
- "/government/statistics/announcements/deaths-registered-by-area-of-usual-residence-in-england-and-wales-monthly-provisional-july-2014"
@Davidslv
Davidslv / The Technical Interview Cheat Sheet.md
Created October 16, 2015 00:15 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.