Skip to content

Instantly share code, notes, and snippets.

View velppa's full-sized avatar
🎯
Focusing

Pavel Popov velppa

🎯
Focusing
View GitHub Profile
@velppa
velppa / 3.hs
Last active August 29, 2015 13:58
Project Euler solutions
-- take step in eratosphen cell by removing all multipliers of x in xs
ec_step :: Integer -> [Integer] -> [Integer]
ec_step 1 xs = xs
ec_step x xs = [ j | j <- xs, mod j x /= 0 ]
-- eratosphen cell recursive
ec_recc :: ([Integer], [Integer]) -> ([Integer], [Integer])
ec_recc (ps, []) = (ps, [])
# rbd at mac-mini in ~/Sites/iseetheline.ru on git:master x [23:27:40]
$ python
Python 2.7.5 (default, Jun 8 2013, 12:45:21)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import timedelta as t
>>> x = t(days=3)
>>> y = t(days=2)
>>> (x-y)*0.5
Traceback (most recent call last):
nmap <buffer> <silent> ]] :call search('\\c^\\<select\\>', 'W' )<CR>
nmap <buffer> <silent> [[ :call search('\\c^\\<select\\>', 'bW' )<CR>
" abbreviations
iab <buffer> maxdate DATE'5999-12-31'
iab <buffer> select SELECT
iab <buffer> from FROM
iab <buffer> and AND
iab <buffer> or OR
iab <buffer> on ON
@velppa
velppa / Ashley.html
Created November 23, 2013 08:27
Ashley theme for Tumblr
<!DOCTYPE html>
<!--
Theme: Ashley v0.5
Author: Jxnblk [http://jxnblk.com]
For: Tumblr [http://tumblr.com/]
Terms: Protected under Creative Commons.
-->
<html lang="en">
__author__ = 'U_M0AZC'
import random
import matplotlib.pyplot as plt
def set_choices(doors=3):
correct_choice = -1
choices = [0 for i in range(doors)]
random.seed()
@velppa
velppa / trollop.rb
Last active December 20, 2015 10:38
require 'trollop'
class Test
attr_reader :a
attr_reader :opts
def initialize
@a = 'qwer'
@opts = Trollop::options do
opt :monkey, "Use monkey mode" # a flag --monkey, defaulting to false
opt :goat, "Use goat mode", :default => true # a flag --goat, defaulting to true
def initialize
@root_dir = File.expand_path(File.dirname(__FILE__) + '/../')
@options = Trollop::options do
opt :asdf,
:type => String,
:default => "#{@root_dir}/qwer"
end
@velppa
velppa / nt.pls
Last active December 19, 2015 02:38
You can't use Nested Table declared in anonymous PL/SQL block in SQL context.
declare
TYPE row_nt IS TABLE OF number;
a row_nt;
cursor a_cur is
select level from dual connect by level <= 100;
n number;
begin
import sys
class ProgressBar():
def __init__(self, num_steps):
self.num_steps = num_steps
def progress(self, step):
i = int(100.0 * step / self.num_steps)
@velppa
velppa / split_join.py
Last active December 16, 2015 00:39
Removes multiple commas in string
', '.join(filter(lambda x: x != '', [x.strip() for x in '[email protected], , , [email protected], , '.split(',')]))