Skip to content

Instantly share code, notes, and snippets.

View alibitek's full-sized avatar
🌱
Growing

Alex Bitek alibitek

🌱
Growing
View GitHub Profile
SELECT round(avg(t1.LAT_N), 4) as median_val
FROM (
SELECT @rownum := @rownum+1 as `row_number`,
s.LAT_N
FROM STATION s,
(SELECT @rownum := 0) r
ORDER BY s.LAT_N
) as t1,
(
SELECT count(*) as total_rows
@alibitek
alibitek / mysql_prime_number_generator.sql
Last active June 4, 2016 16:51
MySQL Sieve of Eratosthenes prime number generator
DELIMITER $$
DROP PROCEDURE IF EXISTS prime $$
CREATE PROCEDURE prime (n INT, OUT res varchar(8000))
BEGIN
DECLARE i smallint DEFAULT 2;
DECLARE j smallint;
DECLARE isPrime bit;
DECLARE result varchar(8000) DEFAULT '';
@alibitek
alibitek / password_verify.php
Created June 2, 2016 07:53
Password bcrypt hash verify
<?php
$hash = '<hash goes here>';
$pass = '<password goes here>';
$hash = password_hash($pass, PASSWORD_BCRYPT);
echo $hash;
if (password_verify($pass, $hash)) {
echo 'Password is valid!';
} else {
@alibitek
alibitek / base_36_to_10.php
Created May 13, 2016 13:40
Base36 to Base10
php -r 'while($code = fgets(STDIN)) { echo base_convert($code, 36, 10) . "\n"; }'
public class Animal<T> {
public T animal;
public void setAnimal(T animal) {
this.animal = animal;
}
public T get() {
return animal;
def retry(howmany):
def tryIt(func):
def f():
attempts = 0
while attempts < howmany:
try:
return func()
except:
attempts += 1
return f
@alibitek
alibitek / system_properties.h
Created February 24, 2016 20:10
platforms/android-21/arch-arm/usr/include/sys/system_properties.h
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
@alibitek
alibitek / test_pretty_function.cpp
Created February 16, 2016 10:28
Test pretty function __PRETTY_FUNCTION__
#include <iostream>
using namespace std;
namespace X { struct F { static void f() { cout << __PRETTY_FUNCTION__; } }; }
// Clang: static void X::F::f()
// GCC: static void X::F::f()
int main() { X::F::f(); }
@alibitek
alibitek / effective_javascript_foreword.txt
Last active February 15, 2016 15:36
Effective JavaScript Foreword
Foreword
As is well known at this point, I created JavaScript in ten days in May
1995, under duress and conflicting management imperatives—“make
it look like Java,” “make it easy for beginners,” “make it control almost
everything in the Netscape browser.”
Apart from getting two big things right (first-class functions, object
prototypes), my solution to the challenging requirements and crazy-
short schedule was to make JavaScript extremely malleable from
the start. I knew developers would have to “patch” the first few ver-
#!/usr/bin/env bash
sudo apt-get install libncursesw5-dev && ./autogen.sh && ./configure --prefix=$HOME && make -j$(nproc) && make -j$(nproc) install