Skip to content

Instantly share code, notes, and snippets.

View gugu's full-sized avatar
🇺🇦

Andrii Kostenko gugu

🇺🇦
View GitHub Profile
@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\",
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 / 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
*/
@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 / 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 / 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/
*