Skip to content

Instantly share code, notes, and snippets.

@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 20, 2024 14:26
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 / Top Bitcoin Dice Games.md
Last active November 17, 2023 10:10
Top Bitcoin Dice Games

Top Bitcoin Dice Games

Curated list of the best Bitcoin Dice games is here. It seems that you're up to play and to win real Bitcoins, but please cool down for a moment and read the notice before you start.

Read before play Bitcoin dice games

This page contains a curated list of awesome Bitcoin betting games that pay. Every game presented has a faucet, so you can claim some free Bitcoins to try the game before actually making your first deposit.

Games listed here, are proven to pay: every game has separate support thread on Bitcointalk forum and pretty huge community behind it. Also, every game listed here is provably fair. It means, that you can test

@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);