Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander Lopatin alopatindev

View GitHub Profile
View monitor-testing.sh
##cvt 3440 1440 60
##xrandr --newmode 3440x1440_60.00 419.50 3440 3696 4064 4688 1440 1443 1453 1493 -hsync +vsync
#xrandr --addmode 3440x1440_60.00 HDMI1
#xrandr --output HDMI1 --mode 3440x1440_60.00
xrandr --output HDMI1 --auto
#xrandr --output HDMI1 --primary
##lcdtest
#arandr
@alopatindev
alopatindev / adb_repull.py
Last active Jun 3, 2020
ADB pull emulation for machines with problematic USB ports/cables. Continuously retries and resumes download when disconnection happens.
View adb_repull.py
#!/usr/bin/env python3
# adb-repull.py
#
# ADB pull emulation for machines with problematic USB ports/cables.
# It continuously retries and resumes download when disconnection happens.
#
# Copyright (c) 2018 Alexander Lopatin
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
View keybase.md

Keybase proof

I hereby claim:

  • I am alopatindev on github.
  • I am alopatindev (https://keybase.io/alopatindev) on keybase.
  • I have a public key whose fingerprint is 1C98 5509 A5F0 7B4D 4DF3 8BCA 44FB 438E DA18 3EF0

To claim this, I am signing this object:

View gradient_descent.py
#!/usr/bin/env python2
# https://www.youtube.com/watch?v=tIpKfDc295M
# https://www.youtube.com/watch?v=umAeJ7LMCfU
import numpy as np
f = lambda x, y: x * x + 2.0 * y
d_dx = lambda x, y: 2.0 * x
d_dy = lambda x, y: 2.0
View diffie_hellman_key_exchange.py
#!/usr/bin/env python2
# https://www.youtube.com/watch?v=YEBfamv-_do
from random import randrange
public_prime = 67280421310721 # aka p
public_base = 3 # aka g
def generate_key():
@alopatindev
alopatindev / Kmeans.scala
Last active May 7, 2017
K-means clustering algorithm
View Kmeans.scala
// https://www.youtube.com/watch?v=_aWzGGNrcic
// https://www.youtube.com/watch?v=RD0nNK51Fp8
import scala.io.Source
import scala.util.Random
import java.io.{BufferedWriter, FileWriter}
object Kmeans extends App {
case class Point(val x: Double, val y: Double) {
View schema.rb
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
View scope-mindfuck.js
let val = 'global 1'
this.val = 'global 2'
console.log('val = ' + val)
class Foo {
constructor() {
this.val = 'property'
}
}
@alopatindev
alopatindev / fib.hs
Created Oct 15, 2016
Fibonacci numbers with Lambda Calculus
View fib.hs
fix :: (a -> a) -> a
fix = \f -> f $ fix f
fib :: Int -> Int
fib = \n -> fix (\f n -> if n <= 2 then 1 else f (n - 2) + f (n - 1)) n
main = putStrLn $ show $ map fib [1..10]
@alopatindev
alopatindev / .gdbinit
Last active Oct 12, 2016
~/.gdbinit enables colors; requires colout
View .gdbinit
set height 0
set pagination off
set disassembly-flavor intel
# Don't wrap line or the coloring regexp won't work.
set width 0
# Create a named pipe to get outputs from gdb
shell test -e /tmp/coloutPipe && rm /tmp/coloutPipe
shell mkfifo /tmp/coloutPipe