Skip to content

Instantly share code, notes, and snippets.

View siberex's full-sized avatar
🛠️
Your stack will not be full without me

Stepan Legachev siberex

🛠️
Your stack will not be full without me
View GitHub Profile
@siberex
siberex / base64.js
Created September 17, 2012 19:48
Encodes binary data or UTF strings to base64 (javascript)
/**
* Base64 encoding. Fast enough.
*
*
* Usage example:
* base64("me@sib.li")
* result: "bWVAc2liLmxp"
*
* UTF strings are also accepted.
*
@siberex
siberex / coroutine.php
Created November 19, 2012 15:33 — forked from nikic/coroutine.php
A coroutine example: Streaming XML parsing using xml_parser
<?php
error_reporting(E_ALL);
/* Data can be send to coroutines using `$coroutine->send($data)`. The sent data will then
* be the result of the `yield` expression. Thus it can be received using a code like
* `$data = yield;`.
*/
/* What we're building in this script is a coroutine-based streaming XML parser. The PHP
// Solution by broc.seib from http://stackoverflow.com/a/15016605/1412330
// Here exists better decoding (not encoding) solution: http://jsbase64.codeplex.com/
// Comparisons between my encoding and solutions from Stackvverflow are here https://gist.github.com/siberex/9089425
decodeBase64 = function(s) {
var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length;
var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for(i=0;i<64;i++){e[A.charAt(i)]=i;}
for(x=0;x<L;x++){
c=e[s.charAt(x)];b=(b<<6)+c;l+=6;
while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<title>Javascript Base64 encoding/decoding</title>
</head>
<body>
<script id="myBase64">
@siberex
siberex / Text loading spinner animation
Last active August 29, 2015 14:01
Simple text loading spinner (., .., ...). Replace 3 with whatever you want (as long as it equals power of two − 1 ^_^) to get more dots :-)
var tSpinnerState = 3|0;
setInterval(function() {
$(".tspinner").text(
new Array( (++tSpinnerState, tSpinnerState &= 3) + 1 ).join(".")
);
}, 275);
@siberex
siberex / encrypted-session-nginx.php
Last active February 27, 2021 02:01
PHP encryption and decryption for Nginx Encrypted Session module
×××××××××××××××××××××××××××××××××××××
MOVED HERE:
https://github.com/siberex/RestyCrypt
×××××××××××××××××××××××××××××××××××××
<?php
/**
* Nginx Encrypted Session module
* Encryption and decryption with PHP
*
لُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ
@siberex
siberex / https.conf
Last active December 16, 2016 13:15
nginx https config
# You can also try SSL Configuration Generator from Mozilla:
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
# ! For HTTP2 with proper ALPN support, please use OpenSSL 1.0.2 or newer
# limit_conn_zone $binary_remote_addr zone=perip:20m;
# HTTP redirect
server {
listen 80;
@siberex
siberex / ng.location.test.html
Last active November 11, 2016 09:40
AngularJS location provider example
<!doctype html>
<html lang="en"
xmlns:ng="http://angularjs.org" id="ng-app" ng-app="awesomeApp"
ng-strict-di="">
<head>
<title>Location test</title>
<base href="/ng.location.test.html/">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
@siberex
siberex / vk-noround.css
Last active August 25, 2016 09:47
VK.com: Get rid off rounded images
/*
VK.com: Get rid off rounded images
User CSS extension for Chrome:
https://chrome.google.com/webstore/detail/user-css/okpjlejfhacmgjkmknjhadmkdbcldfcb/related?hl=en
*/
.nim-peer--photo-w,
.post_img, .reply_img, .cell_img,
.fl_l.thumb,