Skip to content

Instantly share code, notes, and snippets.

View modjke's full-sized avatar

Ignatiev Mikhail modjke

View GitHub Profile
@fulippo
fulippo / .hgignore
Created September 3, 2012 07:48
.hgignore for WordPress
glob:.hgignore
glob:.htaccess
glob:.htpasswd
glob:wp-config.php
glob:wp-content/uploads/*
@lpinca
lpinca / prng.js
Last active January 23, 2023 22:19
Pseudorandom number generator based on crypto.randomBytes
var crypto = require('crypto')
, rrange = 4294967296;
/**
* Return an integer, pseudo-random number in the range [0, 2^32).
*/
var nextInt = function() {
return crypto.randomBytes(4).readUInt32BE(0);
};
@Joncom
Joncom / gist:e8e8d18ebe7fe55c3894
Last active September 11, 2021 00:29
Check if two line segments intersect
// Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345
function line_intersects(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) {
var s1_x, s1_y, s2_x, s2_y;
s1_x = p1_x - p0_x;
s1_y = p1_y - p0_y;
s2_x = p3_x - p2_x;
s2_y = p3_y - p2_y;
var s, t;
@nadako
nadako / Main.hx
Created October 31, 2014 14:38
Structure initialization helper macro
import StructHelper.make;
typedef A = {
a:Int,
b:String,
c:Float,
d:Bool,
e:Array<Int>,
f:{
g:Array<Bool>,
@PowerKiKi
PowerKiKi / generate-wildcard-certificate.sh
Created December 4, 2015 07:31
Generate self-signed wildcard SSL certificate for development environment
#!/usr/bin/env bash
# print usage
DOMAIN=$1
if [ -z "$1" ]; then
echo "USAGE: $0 domain.lan"
echo ""
echo "This will generate a non-secure self-signed wildcard certificate for given domain."
echo "This should only be used in a development environment."
const CASES = [2, 0, 1, 1, 1, 2];
export default function proschet(titles) {
return function bindedProschet(amount) {
return titles[
(amount % 100 > 4 && amount % 100 < 20) ? 2 : CASES[(amount % 10 < 5) ? amount % 10 : 5]
];
};
}
@gr8bit
gr8bit / robinson.js
Created April 6, 2018 13:02
Robinson projection in JavaScript
// Robinson projection calculation
// Written by Niklas Bichinger (bichinger.de). This code is Public Domain - use as you like.
// source of robinson numbers: https://simplemaps.com/static/img/flash/robinson_projection_table.jpg
var robinsonAA = [
0.84870000,
0.84751182,
0.84479598,
0.84021300,
@enepomnyaschih
enepomnyaschih / base64.js
Last active March 6, 2024 23:45
https://www.npmjs.com/package/byte-base64 - Encode JS Uint8Array, simple array of bytes or native JS string to base64 and back
/*
MIT License
Copyright (c) 2020 Egor Nepomnyaschih
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@modjke
modjke / app.js
Last active September 24, 2020 12:49 — forked from adriandmitroca/app.js
Lottie, automatically fixing SVG scaling issue on Internet Explorer 11, but it's actually runnable on Internet Explorer 11 and no jQuery
function lottieIeFixer (el, perspective) {
if (typeof perspective === 'undefined') {
perspective = 'width';
}
if (!window.navigator.userAgent.indexOf('Windows') > -1 &&
!window.navigator.userAgent.indexOf('rv:11.0') > -1) {
return;
}