Skip to content

Instantly share code, notes, and snippets.

#include <locale.h>
#include <stdio.h>
#include <wchar.h>
int main() {
wchar_t name[10];
wcscpy(name, L"жажа");
setlocale(LC_CTYPE, "en_US.UTF-8");
wprintf(L"%S\n", name);
template< class, class >
class Permutation;
template< class OUT_TYPE, class... IN_TYPES, uint32_t... INDEXES >
class Permutation<
std::function< OUT_TYPE (IN_TYPES...) >, // тип целевой функции
UintContainer< INDEXES... > > // перестановка аргументов
{
public:
typedef std::function< OUT_TYPE (IN_TYPES...) > FuncType;
typedef std::function< OUT_TYPE (typename GetNthType< INDEXES, TypeContainer<IN_TYPES...> >::Result...) > NewFuncType;
@mvasilkov
mvasilkov / foo.c
Created February 14, 2012 15:39
Single-malloc char** allocation.
#include <stdio.h>
#include <stdlib.h>
#define N (3)
const size_t offset = sizeof(char *) * N,
length = (sizeof(char *) + sizeof(char) * N) * N;
int main(int argc, char **argv) {
char **foo = (char **)malloc(length);
@mvasilkov
mvasilkov / uwsgi.conf
Created May 19, 2012 19:00
Ricchan (lit.animuchan.net) uWSGI config
description "uWSGI starter {ricchan}"
start on (local-filesystems
and runlevel [2345])
stop on runlevel [016]
respawn
exec /usr/local/bin/uwsgi --uid rei \
-s 127.0.0.1:9001 -M -p 2 \
@mvasilkov
mvasilkov / cemetery.sh
Created July 13, 2012 08:27
Shell commands cemetery ^^
for i in `cat ~/Documents/icons8.txt`; do find . -name "$i" -exec mv {} ~/Projects/icons8/ \;; done
@mvasilkov
mvasilkov / Makefile
Created September 6, 2012 08:32
Makefile for Tako Neko :3
vx:
virtualenv vx
requirements: vx
vx/bin/pip install -r requirements.txt
test_modules = main users
test:
vx/bin/python manage.py test $(test_modules) -v2 --failfast
@mvasilkov
mvasilkov / foo.js
Created October 1, 2012 21:54
TypeScript as a JS pretty print tool
/* Original code */
var s = 'foo.bar', im = new Image
im.src = s; s = im.src
console.log(s)
/* TypeScript output */
var s = 'foo.bar';
var im = new Image();
@mvasilkov
mvasilkov / test.js
Created October 2, 2012 08:56
QUnit test with RequireJS (partial)
define(['events'], function(events) {
module('events.js')
test('Basic methods', function() {
// `register` and `bind`
var str = 'Life is beautiful'
events.register('str_replace')
events.bind('str_replace', function() { str = str.replace('Life', 'Flower') })
@mvasilkov
mvasilkov / requestAnimationFrame.js
Created October 23, 2012 09:12
requestAnimationFrame.js
/*
requestAnimationFrame polyfill, by Mark Vasilkov
http://careers.stackoverflow.com/mvasilkov
Released into the public domain.
*/
if (typeof requestAnimationFrame === "undefined") {
["moz", "webkit", "ms"].some(function(p) {
var fun = this[p + "RequestAnimationFrame"]
if (typeof fun === "function") {
return requestAnimationFrame = fun
@mvasilkov
mvasilkov / failsystem.js
Created October 25, 2012 15:47
FAILSYSTEM lol
function everythingIsRuinedForever(error) {
console.log(error)
}
- function(filename) {
var quota = 1 << 24
webkitStorageInfo.requestQuota(PERSISTENT, quota, function(bytes) {
webkitRequestFileSystem(PERSISTENT, bytes, function(fs) {
console.log(fs.name)