Skip to content

Instantly share code, notes, and snippets.

@iamaziz
iamaziz / github-repo-stars.py
Last active December 29, 2020 20:09
Scrape the stars count of a GitHub repo (beautifulSoup)
from bs4 import BeautifulSoup as bs
import requests
def stars_count(url):
html = requests.get(url).text
soup = bs(html, 'lxml')
stars_class = "social-count js-social-count"
stars = soup.find('a', class_=stars_class).text.strip()
return stars
@paf31
paf31 / UnderscoreFFI.js
Last active January 2, 2021 06:24
Minimal UnderscoreJS Binding for PureScript
"use strict";
// module UnderscoreFFI
exports.map = function(f) {
return function (arr) {
return require('underscore').map(arr, f);
};
};
@evanrelf
evanrelf / effects-with-free.hs
Last active March 10, 2021 22:30
Building a toy effect system with the free monad. And then doing the same thing but with the freer monad, which provides some advantages when writing effect data types.
#!/usr/bin/env nix-shell
#!nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [])"
#!nix-shell -i "ghci"
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
@jsta
jsta / README.md
Created August 26, 2020 12:23
Setup local instance of mediagoblin
@urigoren
urigoren / rshift.py
Last active April 19, 2021 20:50
Use arrow notation (>>) like Haskell to make filter, map and reduce operations more readable.
from itertools import chain
from functools import reduce
import operator
"""
Usage of this module:
<iterable> >> function3 * function2 * function1 >> aggregation
for example:

The Why and When of Choosing Elm

What is Elm?

  • Language (and "framework") for building web frontend applications
  • Can be used in place of HTML, CSS and JavaScript
  • Compiles into the above
@39ff
39ff / y.php
Created January 31, 2016 22:03
データベースに知恵袋のカテゴリをすべて挿入
<?php
//api -> database
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request(
'GET',
'http://chiebukuro.yahooapis.jp/Chiebukuro/V1/categoryTree',
[
'query'=>[
@wasamasa
wasamasa / emacsrepl.el
Last active May 19, 2021 06:22
emacsrepl++
;; https://github.com/antirez/linenoise
;; console_codes(4)
(defvar column-start "\e[0G")
(defvar delete-to-end "\e[0K")
(defvar retreat-cursor "\e[%sD")
(defvar advance-cursor "\e[%sC")
(defvar clear-screen "\e[H\e[2J")
(defun read-byte ()
@wasamasa
wasamasa / exapunks-nonograms.md
Created October 29, 2018 08:33
Transcription of the nonograms in the 2nd EXAPUNKS zine

EASY

                              1  4
                           1  1  1  4
                     3  2  3  1  1  1  7  4  4
                 15  5  6  3  5  3  5  3  6  4 15

              11
            3  6
@wasamasa
wasamasa / traffic-lights.el
Created March 30, 2016 07:54
Finite state machine
(defun traffic-lights ()
(let ((state 'red))
(while t
(cond
((eq state 'red)
(message "Red")
(sleep-for 1)
(setq state 'red+yellow))
((eq state 'red+yellow)
(message "Red+Yellow")