Skip to content

Instantly share code, notes, and snippets.

View nevkontakte's full-sized avatar
👽
Pretending to be smart

Nevkontakte nevkontakte

👽
Pretending to be smart
View GitHub Profile
@nevkontakte
nevkontakte / binary.cc
Created December 9, 2012 13:56
Function to generate binary representation of arbitrary numeric type. Fast. Not thread-safe.
#include <iostream>
template<typename T> char* binary(T n) {
const int bits = sizeof(T)*8;
static char str[bits+1];
str[bits] = 0;
for(int i = 0; i < bits; i++) {
str[bits-i-1] = '0' + (n & 1);
n = n >> 1;
}
@nevkontakte
nevkontakte / ubuntu-cloud-bootable.sh
Created June 26, 2013 10:03
Make Ubuntu Cloud images bootable in virtualbox. Pre-requirements: qemu-img (package qemu-utils in Ubuntu repo), extlinux Tested under Ubuntu 13.04, might work on other linux distros. Get ubuntu image: http://cloud-images.ubuntu.com/precise/current/*.img
#!/bin/bash
##
## Usage: sudo ubuntu-cloud-bootable.sh precise-server-cloudimg-amd64-disk1.img
##
set -e
mount_point="$(mktemp -d)"
raw="$(mktemp)"
echo ">>> Converting to raw: $raw ..."
@nevkontakte
nevkontakte / CLion_Ninja.md
Last active May 28, 2023 11:21
Ninja support for CLion IDE

Ninja support for CLion IDE

This script enables Ninja-powered builds in CLion IDE by wrapping around CMake, which it uses. See my blog post for details.

Disclaimer

This script is provided AS IS with no guarantees given or responsibilities taken by the author. This script relies on undocumented features of CLion IDE and may lead to instability of build and/or IDE. Use it on your own risk under WTFPL terms.

@nevkontakte
nevkontakte / scratchpad.txt
Last active September 23, 2020 10:54
Browser scratchpad using ACE editor (https://ace.c9.io/)
data:text/html;charset=utf-8,
<title>ScratchPad</title>
<link rel="shortcut icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAACYQAAAmEBwTBV+gAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAALVSURBVDiNpZVdSJNRHMaf993aJnvzFc9xLpXhppvIJkUGpgMjjBKCQkdRgjHQiLrpJqmwK7upW7sJIoqCAvu4tKLVTRCTSisaSAPbpg2dtZxb07mPfzcqan5s7sAD5z2c8+P5P+fjBREhXzHGCiRJemu32x/39vYyIoJARMintbe3a1Uq1XuXy2XQarVz09PT4YqKiiYxHyjnXBEMBp87HI46p9NZoFard8myrPV6vbfzKV9gjN1jjMWbm5sjQ0ND1NfX91cUxVkAD/IB9zPGEiaTacpsNlNjY2N4cHAw3dnZ+QWAYltRcM6vAziv0+l+KxQKXTKZ/ON2uxe6urreJRIJOxGlc948znkPgBvV1dWT4XC4LJVKxXw+3wwR+TQazZG5ubk4AOTkmHN+DsBNq9X6MxwOl6XT6Xm/3z9NRCHO+dElKIDsjxvnvAPAQ4PBEIjFYpWZTGZhcnJy3Gg0KqPR6D6fz/dr5fyswJzzYwCeMcb8RFRFROlEIvGDiDSFhYUNHo8nuHbNllFwzlsADEiSNAagiogoFAqN6vX64vLy8kPrQbd0zDlvBPBarVZPSJJUQ0SIxWLfbDabcXR0tCEQCHg2WruhY875bgCDSqVyGRqPx7+aTKaqYDDYuhl0Q8fFxcU2URTfKBSKmaKiIgsRIRqNftbr9bWRSOT42NjYq82g6zoWBEGw79/rUiqV87IsWxbLH7FYLLaJiYmT2UAB4L+reqaj7fK41009F51Js
# This is a higher-level Keras implementation of mountain_car_v2_tf_modernized.
#
# Algorithm: TD Advantage Actor-Critic.
#
from sklearn import preprocessing
from tensorflow import keras
from tensorflow.keras import layers
import gym # requires OpenAI gym installed
import tensorflow as tf
<?php
/**
* Rapid tempalte class
*
* Rapid Template is a powerful and fast template engine. Template syntax very similar to phpBB Templates and is very simple.
* Rapid Template provides full separation of design from code.
* @package RapidTemplate
* @author Alek$ <aleks@aradmin.org>
*/
<?php
/**
* FakeBurner
* FeedBurner counter imitator / Имитатор счетчика FeedBurner
* Originally written for Zebrum Bloglike (http://zebrum.net.ru)
*
* @author Alek$ <aleks@aradmin.org.ru> http://nevkontakte.org.ru
* @copyright Alek$, 2009
* @license GNU General Public License v 2
*/
<?php
/**
* Simple mutex implementation
*
* This class implements sime kind of mutex using PHP's session file lock feature.
* To be short, PHP forces serial access for processes trying wokr with the same session file.
* This is the most simple mutex imitation (flock() is a strange function with unpredictable bugs),
* but this method has some disadvantages and limitations which you should be aware of:
* 1) Using such mutexes together with native PHP sessions can cause unexpected behaviour and possible
* session DATA LOSS!
@nevkontakte
nevkontakte / update-go.sh
Created June 19, 2021 14:46
A little helper script to help updating Go toolchain version on Linux.
#!/bin/bash
set -e;
if [[ "$1" != "" ]]; then
VERSION="go${1}.linux-amd64"
else
VERSION="$(curl -s -S https://golang.org/VERSION?m=text).linux-amd64";
fi
module playground/repro/008-syscall-js-modules
go 1.16
require github.com/gopherjs/gopherjs v0.0.0-20210722203344-69c5ea87048d // indirect