Skip to content

Instantly share code, notes, and snippets.

View arcolife's full-sized avatar

Archit Sharma arcolife

View GitHub Profile
@spranesh
spranesh / dispatch.py
Created May 21, 2011 09:43
Dynamic Dispatch in Python
def Analyse(obj):
""" Dynamic Dispatch based on object's class type.
This will call the AnalyseClassName
Example: if obj is of type Let, then call AnalyseLet,
if it is of type IfElse call AnalyseIfElse
"""
# Get obj's class name
class_name = obj.__class__.__name__
# Create the function name as a string
@fx86
fx86 / string_similarity.py
Created May 28, 2016 11:15
A much more effective algorithm for string similarity found on Stack Overflow
import wikipedia
def get_bigrams(string):
'''
Takes a string and returns a list of bigrams
'''
s = string.lower()
return [s[i:i+2] for i in xrange(len(s) - 1)]
def string_similarity(str1, str2):
@yehosef
yehosef / query.json
Last active November 22, 2016 21:03
elasticsearch avg problem
{
"size": 0,
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*",
"analyze_wildcard": true
}
},
@Ladas
Ladas / count_records.rb
Last active August 20, 2017 11:42
Models Count for Containers, run as ```bundle exec rails r count_records.rb```
classes = [
Authentication,
ComputerSystem,
Container,
ContainerBuild,
ContainerBuildPod,
ContainerComponentStatus,
ContainerCondition,
ContainerEnvVar,
ContainerGroup,
@Ladas
Ladas / ovirt_count_records.rb
Created August 1, 2017 07:04
Count ovirt records, run as: bundle exec rails r ovirt_count_records.rb
classes = [
ManageIQ::Providers::Redhat::InfraManager,
EmsFolder,
EmsCluster,
ResourcePool,
Host,
Vm,
Relationship,
Storage,
MiqEventDefinition,
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ovirtsdk4 as sdk
import ovirtsdk4.types as types
import time
import sys
def create_all():
try:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zhangjiannan
zhangjiannan / gist:e2cc1ea22c7a0e5da3dc134d5c89072a
Created January 14, 2018 02:43
TrueChain ERC20 Distribution
/**
* Overflow aware uint math functions.
*
* Inspired by https://github.com/MakerDAO/maker-otc/blob/master/contracts/simple_market.sol
*/
pragma solidity ^0.4.11;
/**
* ERC 20 token
*
@arcolife
arcolife / encrypt_with_public_key.md
Last active August 4, 2018 00:54
gpg keys generation / import / encryption with someone's public key

Import someone's public GPG key

# Down his public key and saving it to the file key.asc.
# Then use the following command to add it to your keyring:
$ gpg --import <path to key.asc>

# ..check if imported successfully:
$  gpg --list-keys
from casperlabs_client import CasperLabsClient, bundled_contract
from casperlabs_client.abi import ABI
import os
def read_hex_id(file_name):
with open(file_name) as f:
return f.read().strip()
REPO_DIR = f"{os.getenv('HOME')}/CasperLabs"
STORED_TRANSFER_WASM = f"{REPO_DIR}/execution-engine/target/wasm32-unknown-unknown/release/transfer_to_account_u512_stored.wasm"