Skip to content

Instantly share code, notes, and snippets.

@ozh
ozh / markdown_image_border.md
Created May 14, 2020 16:30
Image border in markdown

Image in markdown: no style possible

![alt-text](https://raw.githubusercontent.com/YOURLS/YOURLS/1.7.9/images/yourls-logo.png)

alt-text

IMG tag accepts no style

<img src="https://raw.githubusercontent.com/YOURLS/YOURLS/1.7.9/images/yourls-logo.png" border="1px solid red"/>

@FradSer
FradSer / iterm2_switch_automatic.md
Last active October 8, 2024 12:39
Switch iTerm2 color preset automatic base on macOS dark mode.

The latest beta (3.5) includes separate color settings for light & dark mode. Toggling dark mode automatically switches colors.

Vist iTerm2 homepage or use brew install iterm2-beta to download the beta. Thanks @stefanwascoding.


  1. Add switch_automatic.py to ~/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch with:
sudo yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel -y
mkdir ~/ffmpeg_sources
# nasm
cd ~/ffmpeg_sources
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2
tar xjvf nasm-2.14.02.tar.bz2
cd nasm-2.14.02
./autogen.sh
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
.w-25 {
width: 25% !important;
}
.w-50 {
width: 50% !important;
}
.w-75 {
@joepie91
joepie91 / random.md
Last active January 29, 2025 17:17
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@jfmengels
jfmengels / lodash-fp-documentation.md
Last active January 15, 2025 00:34
Generated docs for Lodash/fp. Help make them better at https://github.com/jfmengels/lodash-fp-docs
@tadjik1
tadjik1 / webpack.config.js
Created December 25, 2015 14:02
webpack.config.js
import path from 'path';
import webpack, { DefinePlugin, BannerPlugin } from 'webpack';
import merge from 'lodash/object/merge';
import autoprefixer from 'autoprefixer';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import minimist from 'minimist';
import { getTemplates } from './html';
const parameters = minimist(process.argv.slice(2))._;
@izqui
izqui / gist:62f11cb52e63f9818e93
Created December 23, 2014 11:48
Swift Async functions
func mapParallel <A, B> (values: [A], task: ( (A, (B) -> () ) -> () ), callback:([B]) -> ()) {
let tasks: [((B) -> ()) -> ()] = values.map({
v in
return {
cb in
task(v, cb)
}
})
@ningsuhen
ningsuhen / Regex.swift
Last active April 27, 2019 18:39
Swift extension for Native String class to support Regex match and Regex replace. Credit - http://www.swift-studies.com/blog/2014/6/12/regex-matching-and-template-replacement-operators-in-swift
import Foundation
struct Regex {
var pattern: String {
didSet {
updateRegex()
}
}
var expressionOptions: NSRegularExpressionOptions {
didSet {
@marbemac
marbemac / gist:06c5040e4d71694f07b3
Created September 8, 2014 21:08
Ember.js custom serializer for consistent JSON root
// API return format is as so:
// {
// data: [
// {
// name: 'foo'
// },
// {
// name: 'bar'
// }
// ]