Skip to content

Instantly share code, notes, and snippets.

View gugu's full-sized avatar
🇺🇦

Andrii Kostenko gugu

🇺🇦
View GitHub Profile
@gugu
gugu / sha1
Created August 14, 2012 18:54
SHA1
// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level ADVANCED_OPTIMIZATIONS
// ==/ClosureCompiler==
/**
*
* Secure Hash Algorithm (SHA1)
* http://www.webtoolkit.info/
*
@gugu
gugu / staticurl.rb
Created September 8, 2012 11:58
sass-staticurl-plugin
require "rubypython"
ENV["DJANGO_SETTINGS_MODULE"] = "settings"
ENV["PYTHONPATH"] = "."
RubyPython.start(:python_exe => ENV["PYTHON_EXECUTABLE_NAME"])
RubyPython.import('imp').load_source("activate_this",File.join(File.dirname(RubyPython::Runtime.python), "activate_this.py"))
$versioning = RubyPython.import("staticutils.versioning")
$settings = RubyPython.import("django.conf").settings
$storage = RubyPython.import("django.core.files.storage")
$fs_storage = $storage.FileSystemStorage(location=$settings.VERSIONED_STATIC_ROOT)
@gugu
gugu / timelocal.c
Last active December 31, 2015 18:48
#include <time.h>
#include <stdio.h>
int main() {
setenv("TZ", ":Europe/Berlin", 1);
tzset();
struct tm t = {0,21,2,25,9,98,0,0,-1};
struct tm t_min = {0,21,1,25,9,98,0,0,-1};
struct tm t_max = {0,21,4,25,9,98,0,0,-1};
printf("is_dst before: %d\n", t.tm_isdst);
@gugu
gugu / test.js
Last active January 10, 2017 12:21
prettydev
/*
To create your own command you need:
1. create gist with name "prettydev"
2. write JS file in requirejs syntax, which returns object with functions. Like this example
To call it you need to write your github login, colon and command name.
For example: gugu:javascript 2+3
*/
POST /links/create/yourdoma.in HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization: WRZgCztHImJoqdWO
Connection: keep-alive
Content-Length: 38
Content-Type: application/json
Host: shorturl.localhost
User-Agent: HTTPie/0.9.2
@gugu
gugu / api.php
Created November 15, 2016 21:26
<?
$url = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$escaped_url = htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.short.cm/links");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"domain\": \"tuneup.fit\",
# To reproduce issue, call tasks.leak_channels.delay().get()
from celery import Celery, chord
app = Celery('tasks', broker='pyamqp://guest@localhost//', backend='redis://127.0.0.1/')
@app.task
def add(x, y):
return x + y
@app.task
### Keybase proof
I hereby claim:
* I am gugu on github.
* I am kostenko (https://keybase.io/kostenko) on keybase.
* I have a public key ASBH4UFBHP2QbipSiuKorkmPKt7NBhzyt2WhGiulCn-kGAo
To claim this, I am signing this object:
{
"totalClicks": 115,
"humanClicks": 0,
"clickStatistics": {
"labels": [
"Mar'17",
"Apr'17",
"May'17",
"Jun'17",
"Jul'17",
@gugu
gugu / slow.py
Created December 19, 2017 04:56
# Возвращаем элементы первого массива, которые есть во втором
import random
import time
def intersection_with_loops(first_array, second_array):
result = []
for first_element in first_array:
if first_element in second_array:
result.append(first_element)
return result