Skip to content

Instantly share code, notes, and snippets.

View RavisMsk's full-sized avatar
🗿

Nikita Anisimov RavisMsk

🗿
View GitHub Profile
@RavisMsk
RavisMsk / .thyme_aliases.sh
Last active October 5, 2016 07:36
thyme straps with daily rotation
# Thyme is a time tracking utility -- https://github.com/sourcegraph/thyme
thyme_up() {
pushd ~/thyme
if [ -f thyme_pid ];
then
THYMEPID=$(cat thyme_pid)
if ps -p $THYMEPID > /dev/null
then
echo "thyme pid file exists and process is UP"
else
@RavisMsk
RavisMsk / app_logging.py
Created February 12, 2016 13:52
Extending Python logging with new levels
# import it like this:
# import app_logging as logging
import logging
from logging import *
GENERIC_LVL_NAME = "GENERIC" #Thats our new mixed-in level
GENERIC_LVL = 100
logging.basicConfig(
@RavisMsk
RavisMsk / gist:ecf4fb9e9cc02cc2e06b
Created March 20, 2015 20:34
Count lines in files in git
git ls-files | xargs wc -l
myAwesomeApp
|-client
| |-lib #Only Client libraries
| |-js
| |-templates
|-collections #Define, Publish & Subscribe collections
|-lib #Isomorphic (Client + Server) libraries
|-private #files & folders avaliable via http
| |-css
| |-other
@RavisMsk
RavisMsk / gist:b6f67036c4782981c5f1
Created November 6, 2014 13:40
Mongo - generate 2.5kk codes with hashcodes.
var symbols = '23456789QWERTYUPASDFGHJKZXCVBNM';
var qty = 2500000;
var length = 7;
var code, hash, i, maxIndex, rand, symbol, _i, _j;
maxIndex = symbols.length - 1;
for (i = _i = 1; 1 <= qty ? _i <= qty : _i >= qty; i = 1 <= qty ? ++_i : --_i) {
code = '';
hash = 0;
for (symbol = _j = 1; 1 <= length ? _j <= length : _j >= length; symbol = 1 <= length ? ++_j : --_j) {
rand = Math.floor((Math.random() * maxIndex) + 1);
@RavisMsk
RavisMsk / UILabel+Visible.h
Created August 13, 2014 21:29
The Lost "Visible" Property
//
// UILabel+Visible.h
// Gisting
//
// Created by Anisimov Nikita on 14.08.14.
// Copyright (c) 2014 Anisimov Nikita. All rights reserved.
//
#import <UIKit/UIKit.h>
@RavisMsk
RavisMsk / gist:6377617
Created August 29, 2013 12:45
Scale UIWebView contents to view width using javascript
[_webView stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:@"var result = '';"
"var viewport = null;"
"var content = null;"
"var document_head = document.getElementsByTagName( 'head' )[0];"
"var child = document_head.firstChild;"
"while ( child )"
"{"
" if ( null == viewport && child.nodeType == 1 && child.nodeName == 'META' && child.getAttribute( 'name' ) == 'viewport' )"
" {"
@RavisMsk
RavisMsk / gist:6363045
Created August 28, 2013 07:22
Method for getting current app version
- (NSString *)appNameAndVersionNumberDisplayString {
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *appDisplayName = [infoDictionary objectForKey:@"CFBundleDisplayName"];
NSString *majorVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString *minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"];
return [NSString stringWithFormat:@"%@, Version %@ (%@)",
appDisplayName, majorVersion, minorVersion];
}
@RavisMsk
RavisMsk / Boyer-Moore Analyzer.py
Last active December 15, 2015 07:09
Boyer-Moore Algorithm implementation for analyzing apache logs.
#Copyright (c) 2013 Anisimov Nikita
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
#documentation files (the "Software"), to deal in the Software without restriction, including without limitation
#the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
#to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of
#the Software.
@RavisMsk
RavisMsk / BinPolynomial.py
Last active July 17, 2018 13:59
This module works with binary polynomials, written in python. Supported: sum, multiplication, division(with quotient and remainder being returned). Being run as main, will perform test.
#Copyright (c) 2013 Anisimov Nikita <ravis.bmstu at gmail dot com>
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
#documentation files (the "Software"), to deal in the Software without restriction, including without limitation
#the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
#to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of
#the Software.