Skip to content

Instantly share code, notes, and snippets.

@oyd11
oyd11 / same-type.cpp
Created January 28, 2018 10:52
same-type created by KobiKaiKai - https://repl.it/@KobiKaiKai/same-type
#include <iostream>
template<typename T>
bool is_same_type(T a,T b) {
return true;
}
template<typename T, typename S>
bool is_same_type(T a,S b) {
return false;
slowcat - the webapp
# Julia 0.6 syntax:
# motivate: wanted a 'trait' like way to get from 'Int16' to 'UInt16'
# there must be a standard way to do that
parse_signed_Int16( str) = signed( parse( UInt16, str ) )
# define: (must have some standard def?)
@oyd11
oyd11 / HOW-i-DuZ-YR-FiB-3Wayz.lol
Created November 24, 2017 23:35
HOW-i-DuZ-YR-FiB-3Wayz created by KobiKaiKai - https://repl.it/@KobiKaiKai/HOW-i-DuZ-YR-FiB-3Wayz
HAI 1.2
HOW DUZ I FiBl00p YR n
I HAS A i ITZ 0
I HAS A a ITZ 1
I HAS A b ITZ 1
IM IN YR l00p UPPIN YR i TIL BOTH SAEM i AN n
@oyd11
oyd11 / fib.hs
Created November 6, 2017 13:59
fib created by KobiKaiKai - https://repl.it/No2c/3
fib :: Int -> Int
fib 0 = 1
fib 1 = 1
fib n = fib(n-1) + fib(n-2)
main = print (fib 6)
@oyd11
oyd11 / fibonacci-tail.js
Created November 6, 2017 13:59
fibonacci-tail created by KobiKaiKai - https://repl.it/No05/1
// fibonacci seq - naïve, and tail recursion
function fib_r(n) {
return n <= 1 ? 1 : fib_r(n - 1) + fib_r(n - 2)
}
console.log(fib_r(5));
function fib_tail_rec(n) {
f = function(f_1, f_2, n) {
@oyd11
oyd11 / FinishedPlayingDelegate.swift
Last active June 25, 2017 09:12
Trying to get actual _play_ time of an audio-clip in iOS
import Foundation
import AVFoundation
/**
Set as a delegate for a _AVAudioPlayer_ instance,
to measure when an audio-clip was in-fact played.
Specifically - when recording a player device,
@oyd11
oyd11 / niqqudless.jl
Last active June 5, 2017 07:21
Niqqud removing function, part of some Hebrew unicode utils
# niqqud utils:
get_alpha(str) = filter(isalpha,str)
niqqudless(str) = map(graphemes(str)) do g
isempty(get_alpha(g))? g : get_alpha(g)
end |> join
# test:
str = "מָרְדֳּכָי"
expect = "מרדכי"
// At last: in C++11 and on - we can do multiple 'return'/assigments in C++
// Compile:
// $ c++ -std=c++11 -stdlib=libc++ fib.cc && ./a.out
#include <tuple>
using namespace std;
// "Python style" swap:
int fib(int n) {
"use strict";
// geez to latin script ::
// alt:
// s=document.getSelection();for(i=0;i<frames.length;i++){if(s)break;s=frames[i].document.getSelection();}if(!s)void(s=prompt('Enter search terms for Wikipedia',''));wikiw=open('http://en.wikipedia.org/'+(s?'w/wiki.phtml?search='+s:''));wikiw.focus();