Skip to content

Instantly share code, notes, and snippets.

View paveljurca's full-sized avatar
🎯
Focusing

Pavel paveljurca

🎯
Focusing
View GitHub Profile
#define _CRT_SECURE_NO_WARNINGS
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <Windows.h>
#include <Wincrypt.h>
@tomkowz
tomkowz / AsyncBlockOperation.swift
Created May 9, 2017 06:48
Asynchronous NSBlockOperation
import Foundation
class AsyncBlockOperation: NSOperation {
typealias Block = (Void -> Void) -> Void
private let block: Block
private var _executing = false
private var _finished = false
init(block: Block) {
@mobz
mobz / isdst.md
Last active November 22, 2017 10:46

Investigations show that ALL timezones that observe DST are in DST

  • Jan 1st (southern hemisphere) or
  • July 1st (northern hemisphere)

No binary search is required to simply know if a given moment is observing dst.

This allows us to imagine the following algorithm

var getTimezoneOffset = require('get-timezone-offset');
@justincbagley
justincbagley / How_to_Convert_Markdown_to_PDF.md
Last active March 27, 2025 03:38
How To Convert Markdown to PDF

How to convert markdown to PDF:

This post reviews several methods for converting a Markdown (.md) formatted file to PDF, from UNIX or Linux machines.

Using Pandoc:

$ pandoc How_I_got_svg-resizer_working_on_Mac_OSX.md -s -o test1.pdf
@kdzwinel
kdzwinel / scroll_to.js
Created May 2, 2017 10:24
Scroll to element or scroll by value
let rafId;
function scrollToElement(el, offsetTop = 0) {
scrollByValue(el.getBoundingClientRect().top - offsetTop);
}
function scrollByValue(offsetTop = 0) {
if (offsetTop !== 0) {
if (rafId) {
cancelAnimationFrame(rafId);
@nathansmith
nathansmith / javascript_gotchas.js
Last active March 1, 2022 16:11
JavaScript "gotchas" from a presentation to coworkers at TandemSeven.
/*
The following are examples of quirky and/or funny
JavaScript "gotchas". This file isn't meant to be
run in its totality. Rather, each section that is
deliniated with "// === //" style comments should
be run separately, using a browser's dev console.
I suggest trying these snippets on localhost
or "example.com" in order to see some of the
"phantom domain" image and iframe examples.
@mobz
mobz / getTimeZone.js
Last active February 26, 2020 09:08
You can scrape the timezone database in javascript using the Intl object [ licensed CC0 ]
function getTimeZone( tz_str, date ) {
const utc_c = {
timeZone: "UTC",
hour12: false,
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
#!/bin/sh
getmod () {
curl -A "curl; used by https://metacpan.org/author/KHEDIN" \
-XPOST https://fastapi.metacpan.org/v1/release/_search -d '{
"size": 5000,
"fields": [ "author", "name" ],
"filter": {
"and": [

ApprovalVotingForPresident.com

What is Approval Voting?

This is how we do it now:

Plurality voting as Radio box example

This is how we could be doing it: