Skip to content

Instantly share code, notes, and snippets.

(ns tom
(:require
[clojure.pprint :as pprint]
)
(:import [tom IFizzBuzz])
(:gen-class)
)
(defn FizzBuzz
@anon767
anon767 / gist:119fe4e911e1ba9325fa3d1d171772b4
Last active September 20, 2017 07:13
Class to handle many concurrent open file handles in nodejs
//Script in case you get following error in your project
/*
Error: EMFILE: too many open files, open '%file%'
at Error (native)
*/
var fs = require('fs');
var fsHandler = function(callBack){
var queue = [];
var semaphore = 0;
@anon767
anon767 / githubviews.java
Last active September 13, 2017 19:01
[Java] small script to get the amount of views and unique visitors of all of your github repos using kohsuke github API
/**
* Created by tom on 13.09.2017.
*/
import org.kohsuke.github.*;
import java.io.IOException;
public class Main {
private static final String userid = "username";
@anon767
anon767 / smsbla
Last active January 11, 2018 11:11
#lang racket/base
(define costfunction
(lambda (stg freisms kostenprosms x)
(+ (- stg ( * freisms kostenprosms)) (* kostenprosms x) )
)
)
;tolerance
(define EPS 1e-3)
@anon767
anon767 / main.c
Created February 16, 2018 16:21
oop in C
#include <stdlib.h>
#include <cstdio>
typedef struct {
int age;
char *name;
void (*eat)(const void *self);
} Animal;
@anon767
anon767 / gameoflife.c
Last active February 18, 2018 21:21
game of life in C and openmpi
#include <endian.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <sys/time.h>
(defn sum [oneDimArr]
(reduce + oneDimArr)
)
(defn singleHourGlassSum [arr , i , j]
(sum
(vector
(get-in arr [i j])
(get-in arr [i (+ j 1)])
(get-in arr [i (+ j 2)])
#include <bits/stdc++.h>
using namespace std;
const int BOARDSIZE = 16;
int sumVector(vector<int> arr){
int sum_of_elems = 0;
for (auto& n : arr)
sum_of_elems += n;
return sum_of_elems;
}
@anon767
anon767 / stock.js
Created January 13, 2019 11:06
retrieve simple and easy stock exchange information for nodejs
const url = "https://query1.finance.yahoo.com/v8/finance/chart/";
const parameter = "?region=US&lang=en-US&includePrePost=false&interval=1m&range=max&corsDomain=finance.yahoo.com&.tsrc=finance"
async function downloadPage(url) {
return new Promise((resolve, reject) => {
request(url, (error, response, body) => {
if (error) reject(error);
if (response.statusCode != 200) {
reject('Invalid status code <' + response.statusCode + '>');
}
resolve(body);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.