Skip to content

Instantly share code, notes, and snippets.

#!/usr/local/bin/python3
from multiprocessing import Process
from threading import Thread
import time
def f(n):
for i in range(n):
i
class Clock:
CREATE OR REPLACE FUNCTION pivot(
refcursor, tablename character varying,
rowc character varying,
colc character varying,
cellc character varying,
celldatatype character varying)
RETURNS refcursor
LANGUAGE 'plpgsql'
COST 100
import java.util.function.Function;
public class MyClass {
private static Function<Integer,Integer> outside(Integer y) {
return new Function<Integer, Integer>() {
@Override
public Integer apply(Integer x) {
return x + y;
}
from datetime import datetime
import logging
import os
import subprocess
logger = logging.getLogger(__name__)
class TcpDump:
def __enter__(self):
now = int(datetime.now().timestamp())
use hyper::{self,Client};
use hyper::rt::{self,Future,Stream};
use hyper_tls::HttpsConnector;
use std::fs::File;
use std::io::prelude::*;
use futures::future;
-module(exercises).
-export([maximum/1,double/1,evens/1, median/1, modes/1]).
maximum([X|Xs]) -> maximum(Xs, X).
maximum([X|Xs], ACC) -> maximum(Xs, max(X, ACC));
maximum([], ACC) -> ACC.
double([X|Xs]) when is_number(X) -> double(Xs, [2*X]).
double([X|Xs], ACC) when is_number(X) -> double(Xs, [2*X|ACC]);
@viniciusd
viniciusd / joining.erl
Created May 24, 2020 22:39
3rd section of the 2nd week of the Functional Programming in Erlang from the University of Kent
-module(joining).
-export([join/2, concat/1]).
reverse([X|Xs]) -> reverse(Xs, [X]);
reverse([]) -> [].
reverse([X|Xs], ACC) -> reverse(Xs, [X | ACC]);
reverse([], ACC) -> ACC.
shunt([],Ys) ->
Ys;
-module(tail_recursion).
-export([is_perfect/1]).
is_perfect(N) ->
2*N == lists:sum(divisors(N)).
divisors(N) ->
divisors(N, 1, []).
divisors(N, I, ACC) when I*I < N andalso N rem I == 0 ->
divisors(N, I+1, [I|[N div I|ACC]]);
The heat bloomed in December .VB
as the carnival season .CV
kicked into gear. .LP
Nearly helpless with sun and glare, I avoided Rio's brilliant .RP
sidewalks
and glittering beaches,
panting in dark corners
and waiting out the inverted southern summer. .JU
-module(billing).
-export([print_bill/1]).
database() ->
[
{1111, "Hula Hoops", 21},
{1112, "Hula Hoops (Giant)", 133},
{1234, "Dry Sherry, 1lt", 540},
{4719, "Fish Fingers" , 121},
{5643, "Nappies" , 1010},