Skip to content

Instantly share code, notes, and snippets.

// http://blog.sandwormz.com/2010/11/rolling-counter-algorithm-pattern.html
class Scratch {
public static void main(String[] args) {
convertPennies(150);
}
public static String[] labels = {"Nickles", "Dimes", "Quarters", "Dollars"};
public static int[] units = {5, 10, 25, 100};
public static void convertPennies(int pennies) {
@elw00d
elw00d / screenshots.js
Last active February 4, 2020 15:50
Скрипт ходит по страницам и делает скриншоты div'а
// Скрипт ходит по страницам и делает скриншоты div'а
// Установка: `npm install puppeteer`
// Запуск: `nodejs screenshot.js`
//
// После работы в директории будет набор файлов 001.png 002.png ... итд
// Чтобы их сконвертировать в pdf, можно воспользоваться imagemagick
//
// # Установить imagemagick
// sudo apt-get install imagemagick
//
namespace
{
inline std::size_t
unaligned_load(const char* p)
{
std::size_t result;
__builtin_memcpy(&result, p, sizeof(result));
return result;
}
/* Точки под Windows 9x/NT/ME/2000/XP */
/* Copyright (c) 2004 by Zealot [WB Team] */
#include <windows.h>
#pragma hdrstop
#include "points.h"
HDC hdc;
PAINTSTRUCT ps;
HPEN hpen;
HBRUSH hbrush;
@elw00d
elw00d / autostart.rc.lua
Created August 29, 2017 07:25
piece of rc.lua at the end of my awesome config
-- После запуска unity-settings-daemon нужно некоторое время подождать, прежде чем
-- менять настройки клавиатуры, иначе unity-settings-daemon может поменять их обратно
-- Наверное, можно как-то по логам демона понять, что он запустился, но пока сделал по-простому
os.execute("pgrep unity-settings-daemon || unity-settings-daemon&")
os.execute("sleep 1.5")
os.execute("setxkbmap -layout \'\' -option")
os.execute("setxkbmap -layout \'us,ru\' -option \'grp:ctrl_shift_toggle\'")
os.execute("setxkbmap -option compose:ralt")
@elw00d
elw00d / patch-xorg-ubuntu-16.04.3.sh
Last active January 9, 2023 17:59
How to patch xorg in ubuntu 16.04.3 (bug of keyboard layout change)
# Bug https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1683383
# Original article https://habrahabr.ru/post/87408/
# create directory
mkdir xorg-server
cd xorg-server
# get sources of required package
# may be need to uncomment 'deb-src' lines in sources.list before
apt-get source xserver-xorg-core-hwe-16.04
@elw00d
elw00d / Dockerfile
Created July 24, 2017 08:21
KeePass dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y wget unzip
RUN wget https://downloads.sourceforge.net/project/keepass/KeePass%202.x/2.36/KeePass-2.36.zip
RUN unzip -d /KeePass KeePass-2.36.zip
# xdotool allows KeePass to initiate autoinput (when you press Ctrl+V)
RUN apt-get update && apt-get install -y mono-complete xdotool
WORKDIR /KeePass/
package ru.yandex;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
/**
* @author elwood
*/
public class Raid {
buildscript {
ext.kotlinVersion = '1.0.4'
ext.kotlinSupportJdk8Version = '0.3'
ext.jacksonVersion="2.7.4"
repositories {
mavenCentral()
}
dependencies {
@elw00d
elw00d / gist:656d6d66b3ec7c6267f1
Last active August 29, 2015 14:05
git cheatsheet
Взять выбранный файле из stash:
git checkout stash@{0} -- <file>
К сожалению, применить все файлы сразу нельзя. А еще чекаут просто заменяет файл на тот, который был в stash. Чтобы применить изменения в виде "патча", надо использовать команду apply:
git stash apply
Алиас команды для добавления в stage только новых файлов (не modified и не deleted):