Skip to content

Instantly share code, notes, and snippets.

View proger's full-sized avatar
🎯
Focusing

Volodymyr Kyrylov proger

🎯
Focusing
View GitHub Profile
kai% seq 10 | awk '{a+=$0} END{print a}'
55
kai% seq 10 | perl -ne '$s+=$_; END {print $s}'
55
kai% seq 10 | perl -e 'while (<>) { $s += $_ }; print $s'
55
kai% seq 10 | ruby -e 'BEGIN{a=0;}' -ne 'a += $_.to_i;' -e 'END{ puts a}'
55
kai% seq 10 | ghc -e 'getContents >>= return . sum . map (\x -> read x :: Int) . lines'
55
[ a = a ] && {
false
} || {
echo haha falltrough
}
@proger
proger / gist:3180858
Created July 26, 2012 07:59
kinda portable way to do isatty() in a shell
% cat t.sh ~
#!/bin/sh
test -c /dev/stdin && echo "char"
test -p /dev/stdin && echo "named pipe"
test -S /dev/stdin && echo "socket"
test ! -f /dev/stdin && echo "not regular"
test -f /dev/stdin && echo "regular"
% sh ./t.sh ~
char
@proger
proger / gist:3263554
Created August 5, 2012 09:55
xcode, what's the fuck?
Process: Xcode [24529]
Path: /Applications/Xcode45-DP3.app/Contents/MacOS/Xcode
Architecture: x86_64
Parent: launchd [359]
UID: 501
Sudden Term: Dirty
Task size: 88682 pages
CPU Time: 8.897s
Thread 0x52e79 DispatchQueue 1 priority <multiple> cpu time 8.895s
% sudo dtrace -Cs ~/dev/darwin/trace/execsnoop.real.d
[2075->2076] /Library/RubyMotion/bin/deploy
[2076->2077] sh -c open http://www.youtube.com/watch?v=1orMXD_Ijbs&feature=fvst
-- finally got to the fact that List is also a monad and it's great
Prelude> replicate 2 [1,2,3]
[[1,2,3],[1,2,3]]
Prelude> :t replicate
replicate :: Int -> a -> [a]
Prelude> :m Control.Monad
Prelude Control.Monad> :t replicateM
replicateM :: Monad m => Int -> m a -> m [a]
Prelude Control.Monad> replicateM 2 [1,2,3]
@proger
proger / iosdtrace.md
Last active March 4, 2024 08:01
iosdtrace.md

DTrace Sessions for iOS Development

DTrace is a comprehensive dynamic tracing framework created by Sun Microsystems for troubleshooting kernel and application problems on production systems in real time. Originally developed for Solaris, it has since been released to open source community in 2004 and has been ported to several other Unix systems.

Apple ported DTrace for OS X Leopard, including a GUI called Instruments and made it co-exist with the existing legacy stack of performance troubleshooting toolkits.

We are going to tame this beast to help us hunt down and eliminate all sorts of application and system-wide troubles when doing development of iOS and OS X apps.

the chat

try {
OtpConnection nconn = self.accept();
} catch (Exception ex) {
ex.printStackTrace();
break;
}
ConnectionConsumer listener;
//
// Specific Crash Example.m
// Specific Crash Example.m
//
// Created by Paul Taykalo on 09/01/12.
// Copyright (c) 2012 Stanfy LLC. All rights reserved.
//
#import "ACAppDelegate.h"
@proger
proger / check.py
Created September 10, 2012 15:03
как я покупал гантели
import sys
import os
from glob import glob
from datetime import datetime
import requests
import lxml.etree
savedir = os.path.dirname(__file__)
savepath = lambda date: os.path.join(savedir, 'check_%s' % date)
savepathnow = lambda: savepath(datetime.now().strftime('%s'))