Skip to content

Instantly share code, notes, and snippets.

View AlexMikhalev's full-sized avatar

Dr Alexander Mikhalev AlexMikhalev

View GitHub Profile
SELECT * FROM myTable WHERE DATE(myDate) = DATE(NOW())
summa = 0
for A in S:
for P in A.PS:
summa += P.N
-----------------
summa = sum([P.N for A in S for P in A.PS])
@AlexMikhalev
AlexMikhalev / dht_test.ino
Last active August 29, 2015 14:09
DHT22 Sketch for Pinoccio Scout
// Working DHT 22 sketch for Pinoccio
#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <Shell.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
from collections import defaultdict
from operator import itemgetter
def solution(A):
# write your code in Python 2.7
appearances = defaultdict(int)
N=len(A)
for each_key in A:
@AlexMikhalev
AlexMikhalev / create_gce_vm_correct.yml
Created May 5, 2020 18:09
Correct ansible script to create GCE instance
- name: 'Deploy gcp vm'
hosts: localhost
connection: local
become: false
gather_facts: no
vars:
gcp_project: "cord19kaggle"
gcp_cred_kind: "serviceaccount"
gcp_cred_file: "/home/alex/.config/.json"
@AlexMikhalev
AlexMikhalev / create_azure_vm.yml
Created May 5, 2020 18:13
Ansible playbook to create Azure VM
- name: Create Azure VM
hosts: localhost
connection: local
tasks:
- name: Create resource group
azure_rm_resourcegroup:
name: cord19demo
location: westeurope
- name: Create virtual network
azure_rm_virtualnetwork:
@AlexMikhalev
AlexMikhalev / myazure_rm.yml
Created May 5, 2020 18:16
Dynamic Inventory for Azure
plugin: azure_rm
include_vm_resource_groups:
- cord19demo
auth_source: auto
keyed_groups:
- prefix: tag
key: tags
@AlexMikhalev
AlexMikhalev / instances.gcp.yml
Created May 5, 2020 18:19
Ansible dynamic inventory for Google Cloud Platform
plugin: gcp_compute
projects:
- cord19kaggle
auth_kind: serviceaccount
service_account_file: "/home/alex/*.json"
@AlexMikhalev
AlexMikhalev / create_folders.yml
Created May 6, 2020 09:49
Create multiple folders using ansible without changing permissions
---
- name: "Creating multiple by checking folders"
hosts: your_host_name
tasks:
- block:
- name: "Checking folders"
stat:
path: "{{item}}"
register: folder_stats
with_items:
@AlexMikhalev
AlexMikhalev / docker_redismod.yml
Last active May 13, 2020 09:51
Docker based ansible playbook to deploy Redis
---
- hosts: all
become: true
vars:
create_containers: 1
default_container_name: redis
default_container_image: redislabs/redismod
default_container_command: /usr/etc/redis/redis.conf
tasks: