Skip to content

Instantly share code, notes, and snippets.

@define-private-public
define-private-public / nim_opengl_shader_example.nim
Last active September 26, 2019 05:59
An example of using OpenGL shaders (and indexed drawing) in Nim
# File: nim_opengl_shader_example.nim
# Author: Benjamin N. Summerton <define-private-public>
# Description: An example of how to use OpenGL shaders in Nim. Draws a simple
# rotating hexagon with 6 colors. Also uses indexed drawing.
#
# Uses this GLFW binding: https://github.com/rafaelvasco/nimrod-glfw, though if
# want to use SDL2, changing out the windowing should be simple.
#
# This was built on Linux using OpenGL ES 3. If you want to use a different
# OpenGL version then you will have to alter the shader source.
@kbussell
kbussell / ctrlTap.lua
Last active February 13, 2021 17:46
Send escape key if the ctrl key is tapped. (Used along side remapping my Caps Lock key to ctrl) Thanks to @asmagill 's examples for a starting point.
local alert = require("hs.alert")
local timer = require("hs.timer")
local eventtap = require("hs.eventtap")
local events = eventtap.event.types
local module = {}
-- timeout for ctrol key
module.timeFrame = .25
import dom
type
CanvasRenderingContext* = ref object
fillStyle* {.importc.}: cstring
strokeStyle* {.importc.}: cstring
width* {.importc.}: int
height* {.importc.}: int
shadowColor* {.importc.}: cstring
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 26, 2024 17:59
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
@inaz2
inaz2 / client.c
Created March 4, 2016 08:20
IPv6 server & client in C
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
void ping(int s, char *message)
{
char buf[8192];
@joepie91
joepie91 / vpn.md
Last active May 3, 2024 10:58
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@meiamsome
meiamsome / hn_search.js
Last active May 4, 2022 13:23 — forked from kristopolous/hn_seach.js
hn job query search
/* Hacker News Search Script
*
* Original Script by Kristopolous:
* https://gist.github.com/kristopolous/19260ae54967c2219da8
*
* Usage:
* First, copy the script into your browser's console whilst on the Hacker News
* jobs page. Then, you can use the query function to filter the results.
*
* For example,
@lydell
lydell / bigrams-to-pairs.js
Created August 23, 2015 08:54
English bigram and letter pair frequencies from the Google Corpus Data in JSON format
// By Simon Lydell 2015.
// This file is in the public domain.
var stdin = require("get-stdin")
var tools = require("text-frequencies-analysis")
var helpers = require("text-frequencies-analysis/lib/helpers")
stdin(function(text) {
process.stdout.write(tools.jsonStringifyRow(convert(JSON.parse(text))))
})
@fpsunflower
fpsunflower / nanopng.cpp
Last active January 31, 2023 19:04
Tiny PNG output
// c++ -o nanopng nanopng.cpp && ./nanopng /tmp/foo.png
#include <cstdio>
// write an uncompressed PNG file from a uint8 RGB buffer
struct Png {
FILE*f; unsigned int tab[256], crc; ~Png() { fclose(f); }
Png(const char* fn, int w, int h, const unsigned char* c) {
crc=0x575e51f5;unsigned char d[]={137,80,78,71,13,
10,26,10,0,0,0,13,73,72,68,82,73,68,65,84,120,1,0,
0,0,73,69,78,68,174,66,96,130};/*chunk headers*/
@oleganza
oleganza / gist:8cc921e48f396515c6d6
Last active January 30, 2022 00:06
Proof that Proof-of-Work is the only solution to Byzantine Generals' problem

In reply to "@Vlad_Roberto: No, not a programmer. I just know there's better ways to doing anything without massive energy consumption & Banks."

The problem of blockchain synchronization is the following:

Imagine you are sitting in a bunker. You have no idea what people are out there and what are their intentions. You only receive some incoming messages from strangers that may contain anything. They can be just random garbage or deliberately crafted messages to confuse you or lie to you. You never know. You cannot trust anyone.e

The problem of "money" or any other "social contract" is that everyone should be able to know what the majority agrees to without trusting some intermediaries (otherwise they can easily obuse their special position). If everyone votes for "X", then you sitting in a bunker must somehow independently figure out that all those other people indeed voted for "X" and not for "Y" or "Z". But remember: you cannot trust anyone's message and messages are the only thing you get from the outsi