Skip to content

Instantly share code, notes, and snippets.

@bert
bert / README
Created May 22, 2011 21:20
Draw in a GdkPixbuf with Cairo
A relatively simple application that demonstrates some advanced usage of GdkPixbuf and cairo.
Two most interesting functions are documented inside sources.
// Single-line comments start with //
/*
Multi-line comments look like this.
*/
// Import ArrayList class inside of the java.util package
import java.util.ArrayList;
// Import all classes inside of java.lang package
import java.security.*;
@hawkw
hawkw / HawkLang.md
Last active January 6, 2025 01:44
Random ideas for Programming Language Syntax I'd Like To See. Using Python syntax highlighting for the code snippets because some syntax is similar enough that python-style highlighting improves readability.

Thoughts and Rationale

This isn't a comprehensive language design, it's just ideas for syntactical constructs I'd really like to see some day. It'd probably be some kind of object/functional hybrid a la Scala - I really like the recent trend of "post-functional" languages that take a lot of ideas/influence from functional programming, but aren't fascist about it, or so scary that only math Ph.Ds can learn them. The idea is to fuse OOP and FP into a language which gives you a high level of expressiveness and power, but is actually useable for Getting Real Things Done.

@cuth
cuth / debug-scroll.md
Last active October 18, 2024 08:22
Find the elements that are causing a horizontal scroll. Based on http://css-tricks.com/findingfixing-unintended-body-overflow/

Debug Horizontal Scroll

(function (d) {
    var w = d.documentElement.offsetWidth,
        t = d.createTreeWalker(d.body, NodeFilter.SHOW_ELEMENT),
        b;
    while (t.nextNode()) {
        b = t.currentNode.getBoundingClientRect();
 if (b.right > w || b.left < 0) {
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT &&
iptables -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP &&
iptables -A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP &&
iptables -A INPUT -i lo -j ACCEPT &&
iptables -D INPUT -p tcp -m tcp --dport 21 -j ACCEPT &&
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT &&
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT &&
iptables -A INPUT -p tcp -m tcp --dport 1989 -j ACCEPT &&
iptables -A INPUT -p tcp -m tcp --dport 1500 -j ACCEPT &&
iptables -A INPUT -p tcp -m tcp --dport 18080 -j ACCEPT &&
@averyvery
averyvery / application.rb
Last active May 27, 2024 07:35
Inline CSS or JS in Rails
config.assets.precompile += [
# precompile any CSS or JS file that doesn't start with _
/(^inline[^_\/]|\/[^_])[^\/]*.(js|css)$/,
...
@chicoxyzzy
chicoxyzzy / noncoercible.js
Last active March 15, 2021 17:09
Non-coercible objects
function nonCoercible(val) {
if (val == null) {
throw TypeError('nonCoercible shouldn\'t be called with null or undefined');
}
const res = Object(val);
res[Symbol.toPrimitive] = () => {
throw TypeError('Trying to coerce non-coercible object');
}
return res;
};
@ViktorNova
ViktorNova / rotate-video.sh
Created August 8, 2016 21:33
Rotate a video with FFmpeg (100% lossless, and quick)
$INPUTVIDEO='input.mp4'
$OUTPUTVIDEO='output.mp4'
ffmpeg -i $INPUTVIDEO -metadata:s:v rotate="-90" -codec copy $OUTPUTVIDEO
@JPvRiel
JPvRiel / apt_pinning_priorities.md
Last active June 14, 2025 22:33
Apt package pinning and priorities
@BrianWill
BrianWill / Go overview.md
Last active July 7, 2025 14:14
Go language overview for experienced programmers

The Go language for experienced programmers

Why use Go?

  • Like C, but with garbage collection, memory safety, and special mechanisms for concurrency
  • Pointers but no pointer arithmetic
  • No header files
  • Simple, clean syntax
  • Very fast native compilation (about as quick to edit code and restart as a dynamic language)
  • Easy-to-distribute executables