Skip to content

Instantly share code, notes, and snippets.

@chris-taylor
chris-taylor / Module1.hs
Created June 13, 2012 13:44
Reader monad example
module Module1 where
import Control.Monad.Reader
data Config = Config { arg :: Int }
initialize :: IO Config
initialize = do
n <- getLine
return $ Config (read n)
@thefish
thefish / bootstrap-typeahead-objects-array.js
Created September 5, 2012 12:47
twitter bootstrap typeahead modified to work with array of key-value objects.
/* =============================================================
* bootstrap-typeahead.js v2.1.1
* http://twitter.github.com/bootstrap/javascript.html#typeahead
* =============================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@rblaze
rblaze / bf.c
Last active December 11, 2015 07:08
Специальная олимпиада-2: Bellman-Ford algorithm как первый шаг Johnson algorithm Изначальная версия: haskell - 60 минут, C - две минуты. Данные для обработки: http://spark-public.s3.amazonaws.com/algo2/datasets/large.txt
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const int infinity = 2147483647;
struct edge_t {
int v1;
int v2;
int cost;
@agarzon
agarzon / dnsbl.sh
Last active October 2, 2022 09:04
DNS Black List - Linux shell script (improved from: http://www.daemonforums.org/showthread.php?t=302)
#!/bin/sh
# Check if an IP address is listed on one of the following blacklists
# The format is chosen to make it easy to add or delete
# The shell will strip multiple whitespace
BLISTS="
b.barracudacentral.org
bb.barracudacentral.org
bl.deadbeef.com
bl.mailspike.net
@thefish
thefish / utf8-win1251
Created May 21, 2013 08:31
JS utf-8 to windows-1251 string converter
//utf8 to 1251 converter (1 byte format, RU/EN support only + any other symbols) by drgluck
function utf8_decode (aa) {
var bb = '', c = 0;
for (var i = 0; i < aa.length; i++) {
c = aa.charCodeAt(i);
if (c > 127) {
if (c > 1024) {
if (c == 1025) {
c = 1016;
} else if (c == 1105) {
@thefish
thefish / ddos-autoban.sh
Last active December 23, 2015 03:59
Autoban scripts for dumb DDoS (FreeBSD)
#!/bin/sh
while read count ip
do
test $count -gt 100 && echo " ipfw add deny all from $ip to me"
done
@guewen
guewen / pg_on_ram.sh
Last active January 24, 2020 08:37
Create a PostgreSQL cluster in a ramfs and start the server on this cluster.
#!/bin/bash
PORT=6432
# Create a ramfs
if [ -f /tmp/pg_on_ram ]
then
echo "/tmp/pg_on_ram already exists"
exit 1
fi
@klkvsk
klkvsk / gist:9684458
Created March 21, 2014 11:45
extdoc.php - generate .php from extension
<?php
if ($argc < 2) {
die('Usage: php extdoc.php <extension_name>' . PHP_EOL);
}
$extension = $argv[1];
$keywords = array('__halt_compiler', 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch',
'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty',
'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final',
'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof',
@coopernurse
coopernurse / howto
Last active August 29, 2015 13:57
the world's dumbest Haskell json-rpc example
cabal install scotty
cabal install aeson
runhaskell server.hs
curl -X POST -d '{"jsonrpc":"2.0", "method":"Calc.Add", "params":[10,50], "id":"abc"}' http://localhost:3000/api
@zmts
zmts / tokens.md
Last active July 22, 2024 18:25
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов