Skip to content

Instantly share code, notes, and snippets.

View Newlifer's full-sized avatar

Newlifer

  • Yaroslavl
View GitHub Profile
@Grab('pircbot:pircbot:1.4.2')
import org.jibble.pircbot.*;
def (host, port, channel) = ['chat.freenode.net', 6667, 'gitbot']
def bot = [:] as PircBot
bot.name = 'groovy_bot'
bot.encoding = 'ISO-2022-JP'
bot.connect host, port
bot.joinChannel channel
#include <iostream>
#include <algorithm>
#include <assert.h>
#include <vector>
#include <map>
#include <string>
#include <memory>
import System.Random
randInRange :: Int -> Int -> IO Int
randInRange a b = getStdRandom $ randomR (a, b)
ep :: Int -> IO Int
ep s = if s /= 3 then randInRange 1 26 else randInRange 1 13
main =
@Newlifer
Newlifer / horta-replacer.ps1
Last active August 29, 2015 14:05
Pattern replacer
<#
.DESCRIPTION
This script is for replacing something by pattern in all text files
in specific directory and its subdirectories recursively.
.PARAMETER word
Pattern what we want to replace.
.PARAMETER replace
Replacement.
@Newlifer
Newlifer / substrfilematcher.ps1
Created August 20, 2014 10:41
Searches substring in the files in specific directory, recursively.
param(
$place = $PSScriptRoot,
$what
)
$time1 = Get-Date -format HH:mm:ss
[array]$list = Get-ChildItem $place -recurse | %{ Write-Host Examining file: $_.fullname; $_ } | ? { $_.psiscontainer -eq $false } | ?{ gc $_.pspath | select-string -pattern $what } | %{ $_.FullName }
param(
$place = $PSScriptRoot,
$what
)
$regexPattern = "\\"
if($caseSensitive -eq $false) { $regexPattern = "(?i)$regexPattern" }
$regex = New-Object System.Text.RegularExpressions.Regex $regexPattern
# Function for highlighting pattern in the line.
#include <iostream>
#include <functional>
#include <utility>
#include <array>
#include <map>
using namespace std;
template< typename F, typename Arg >
struct PartialApp {
{-# LANGUAGE OverloadedStrings #-}
import Text.Printf
import Control.Monad
import Data.Char
import Data.List
import System.IO
import Codec.Binary.UTF8.String (utf8Encode)
import qualified Data.Text.Encoding as T
@Newlifer
Newlifer / example.hs
Created November 6, 2015 10:15
simpleHTTP usage example
import Network.HTTP
import Text.RawString.QQ
headers :: [Header]
headers = [
Header (HdrCustom "Connection") "keep-alive"
,Header (HdrCustom "Accept-Language") ";q=0.8,en-US;q=0.5,en;q=0.3"
,Header (HdrCustom "User-Agent") "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"
,Header (HdrCustom "Accept") "application/json, text/javascript, */*; q=0.01"
// MCCME issue 3299
#include <iostream>
#include <tuple>
auto gcd (int a, int b) -> std::tuple<int, int, int> // <GCD, x, y>
{
if (a == 0)
{
return std::make_tuple (b, 0, 1);
}