Skip to content

Instantly share code, notes, and snippets.

@gnaggnoyil
gnaggnoyil / README.md
Created September 9, 2024 09:03 — forked from nikcub/README.md
Facebook PHP Source Code from August 2007
@gnaggnoyil
gnaggnoyil / setrlimit.c
Created November 14, 2022 10:55
Sample program showind differences of behavior on real linux and WSL1
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/resource.h>
@gnaggnoyil
gnaggnoyil / sudo新一.md
Created December 29, 2021 09:22 — forked from greymd/sudo新一.md
sudo新一

 オレは高校生シェル芸人 sudo 新一。幼馴染で同級生の more 利蘭と遊園地に遊びに行って、黒ずくめの男の怪しげな rm -rf / 現場を目撃した。端末をみるのに夢中になっていた俺は、背後から近づいてきたもう1人の --no-preserve-root オプションに気づかなかった。 俺はその男に毒薬を飲まされ、目が覚めたら・・・ OS のプリインストールから除かれてしまっていた!

sudo がまだ $PATH に残っていると奴らにバレたら、また命を狙われ、他のコマンドにも危害が及ぶ』

 上田博士の助言で正体を隠すことにした俺は、 which に名前を聞かれて、とっさに『gnuplot』と名乗り、奴らの情報をつかむために、父親がシェル芸人をやっている蘭の $HOME に転がり込んだ。ところが、このおっちゃん・・・とんだヘボシェル芸人で、見かねた俺はおっちゃんになりかわり、持ち前の権限昇格能力で、次々と難タスクを解決してきた。おかげで、おっちゃんは今や世間に名を知られた名エンジニア、俺はといえばシェル芸 bot のおもちゃに逆戻り。クラスメートの convertojichattextimg にお絵かきコマンドと誤解され少年ワンライナーお絵かき団を結成させられる始末。

 ではここで、博士が作ってくれたメカを紹介しよう。最初は時計型麻酔 kill 。ふたについた照準器にあわせてエンターを押せば、麻酔シグナルが飛び出し、プロセスを瞬時に sleep させることができる。 次に、蝶ネクタイ型 banner 。裏についているダイヤルを調整すれば、ありとあらゆる大きさのメッセージを標準出力できる。必殺のアイテムなら fork 力増強シューズ。電気と磁力で足を刺激し、 :(){ :|:&amp; };: でプロセステーブ

@gnaggnoyil
gnaggnoyil / instructions.md
Created April 18, 2021 06:53 — forked from cvetan/instructions.md
Using pkexec in XFCE

There instructions were first published in debian forum, here http://forums.debian.net/viewtopic.php?f=16&t=73497 but I added them here for easier access

Add policykit file

  • Add XML file on the path /usr/share/polkit-1/actions/org.freedesktop.policykit.pkexec.policy with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
    <action id="org.freedesktop.policykit.pkexec.run-synaptic">

Revision numbers in Git

I come from RCS, where revision numbers are easy to insert into files with RCS keyword strings such as $Revision: $, $Id: $ and $Header: $.

There are various posts around of different ways of using revision numbers in Git, e.g. http://stackoverflow.com/questions/4120001/what-is-the-git-equivalent-for-revision-number

When using tags to record release revision numbers, we can use git describe to obtain reasonable-looking revision numbers, e.g. 1.2.1-2-g17880f1, where 1.2.1 is the most recent tag on the current branch, 2 is the number of commits made since the tag, and 17880f1 is the (short) SHA of the current commit (prefixed with g for "git"). These numbers have the benefit of monotonically increasing in the -<number-of-commits>- part, and presumably you would use some sort of meaningful release revision numbers in tags, so they should be fairly easy to understandy by non-technical people (ignoring the -g<SHA> at the end).

Inserting revision numbers in s

@gnaggnoyil
gnaggnoyil / incbin.c
Created January 22, 2021 09:39 — forked from mmozeiko/incbin.c
Include binary file with gcc/clang
#include <stdio.h>
#define STR2(x) #x
#define STR(x) STR2(x)
#define INCBIN(name, file) \
__asm__(".section .rodata\n" \
".global incbin_" STR(name) "_start\n" \
".balign 16\n" \
"incbin_" STR(name) "_start:\n" \
@gnaggnoyil
gnaggnoyil / Rainmeter\Skins\illustro\nvidia-smi\nvidia-smi.ini
Last active August 28, 2020 17:21
Showing `nvidia-smi` outputs to a rainmeter skin
[Rainmeter]
Update=1000
Background=#@#Background2x.png
BackgroundMode=3
BackgroundMargins=32,68,32,28
OnRefreshAction=[!CommandMeasure "MeasureGPUs" "Run"]
DynamicWindowSize=1
[Metadata]
Name=nvidia-smi
@gnaggnoyil
gnaggnoyil / sudo.ps1
Created March 7, 2020 12:48 — forked from liyafe1997/sudo.ps1
sudo.ps1, sudo for PowerShell, put in C:\Windows then you can sudo in powershell lol. You need sudo.bat(https://gist.github.com/liyafe1997/e036a7c3d4fb3903d567ec6d62c324ef)
If($args){sudo.bat powershell -NoExit -Command "(cd "$pwd");("$args")"}Else{sudo.bat powershell -NoExit -Command "cd "$pwd}
@gnaggnoyil
gnaggnoyil / sudo.bat
Created March 7, 2020 12:48 — forked from liyafe1997/sudo.bat
sudo for Windows, save as sudo.bat put in C:\Windows then you can sudo lol. Powershell see https://gist.github.com/liyafe1997/93be39df5ffee18a1c14a24122576e15
@echo off
powershell -Command "(($arg='/k cd /d '+$pwd+' && %*') -and (Start-Process cmd -Verb RunAs -ArgumentList $arg))| Out-Null"
@echo on
@gnaggnoyil
gnaggnoyil / parse_date.h
Created November 19, 2019 06:33 — forked from qis/parse_date.h
Parse ISO 8601 date time strings in C++ and AVX2.
// if(MSVC)
// set(AVX2_FLAGS "/arch:AVX2")
// else()
// set(AVX2_FLAGS "-march=native -mavx2")
// endif()
//
// option(ENABLE_AVX2 "Enable AVX2 support" OFF)
// if(ENABLE_AVX2)
// if(CMAKE_CROSSCOMPILING)
// set(AVX2 TRUE)