Skip to content

Instantly share code, notes, and snippets.

View vladignatyev's full-sized avatar
🥎
Seeking a job

Vladimir Ignatev vladignatyev

🥎
Seeking a job
View GitHub Profile
@vladignatyev
vladignatyev / dict_to_redis.py
Last active November 23, 2022 01:00
Save Python dict to Redis hash
def dict_to_redis_hset(r, hkey, dict_to_store):
"""
Saves `dict_to_store` dict into Redis hash, where `hkey` is key of hash.
>>> import redis
>>> r = redis.StrictRedis(host='localhost')
>>> d = {'a':1, 'b':7, 'foo':'bar'}
>>> dict_to_redis_hset(r, 'test', d)
True
>>> r.hgetall('test')
@vladignatyev
vladignatyev / pynamegen.py
Created November 24, 2014 18:33
Generate pretty random team names for World's First Global Hackathon teams using Enchant for english words suggestion
import enchant
import random
_EN_ALPHABET = map(chr, range(97, 123))
_NUMBERS = map(str, range(0, 9))
class Names(object):
def __init__(self, character_set=tuple(_NUMBERS + _EN_ALPHABET)):
self.characters = character_set
@vladignatyev
vladignatyev / progress.py
Last active March 31, 2024 22:54
Python command line progress bar in less than 10 lines of code.
# The MIT License (MIT)
# Copyright (c) 2016 Vladimir Ignatev
#
# 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:
#
@vladignatyev
vladignatyev / clean.sh
Created July 26, 2015 18:10
Remove files and directories older than 7 days
find . -mtime +7 -exec rm -rf {} \;
@vladignatyev
vladignatyev / Emscripten Installation on OS X El Capitan 10.11.md
Last active October 3, 2017 07:22
Emscripten: Installation and running on OS X. Workaround for "Cannot find /usr/bin/llvm-link", "could not check fastcomp", "LLVM version appears incorrect (seeing "7.0", expected "3.7")"
@vladignatyev
vladignatyev / APAnalyticsTracker.h
Last active March 28, 2016 17:24
Add Google Analytics into XCode project for iOS, resolving "use of '@import' when modules are disabled” error
//
// APAnalyticsTracker.h
#import <Foundation/Foundation.h>
@interface APAnalyticsTracker : NSObject
+ (void)configureTracker;
+ (void)trackScreenWithName: (NSString*) name;
@vladignatyev
vladignatyev / pandas-mem.py
Last active February 2, 2017 11:26
The example code to check the problem in a question problem, posted on StackOverflow
#!/env/bin/python
# See: http://stackoverflow.com/questions/41893967/increase-in-memory-usage-on-pandas-dataframe-creation/42000635
import sys
import pandas as pd
import gc
# @profile ## uncomment this line if you want to profile with memory-profiler Python's module
def make_list():
pd_arr = []
for i in range(0,10000):
@vladignatyev
vladignatyev / ListAdapter.kt
Created May 21, 2018 12:50
Kotlin + Anko + ButterKnife: helper for async adapter for ListView
package com.github.kotlin.lib
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import butterknife.ButterKnife
@vladignatyev
vladignatyev / testdevice.js
Created May 27, 2018 13:51
Get hardware data from Browser to implement vendor and hardware lock like Google and other shit companies do
console.log("CPU/OS: " + navigator.oscpu);
console.log("Cores count: " + navigator.hardwareConcurrency);
console.log("RAM: " + navigator.deviceMemory);
console.log("Plaform: " + navigator.platform);
console.log("Browser info: " + navigator.userAgent);
console.log("Browser info: " + navigator.product + " " + navigator.productSub);
console.log("Browser info: " + navigator.appCodeName);
console.log("Browser info: " + navigator.appName);
console.log("Browser info: " + navigator.appVersion);
console.log("Vendor: " + navigator.vendor + " " + navigator.vendorSub);
@vladignatyev
vladignatyev / gdpr-list.md
Last active October 1, 2018 07:44
List of countries affected by GDPR