Skip to content

Instantly share code, notes, and snippets.

// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@cosimo
cosimo / parse-options.sh
Created September 21, 2012 09:31
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@branneman
branneman / better-nodejs-require-paths.md
Last active May 15, 2025 11:17
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@kafene
kafene / dnscrypt-installation.md
Last active July 30, 2017 20:09
DNSCrypt Installation

Create and enter a working directory

mkdir -p ~/dnscrypt-working-directory && cd ~/dnscrypt-working-directory

Become root

sudo -s
@steve-ng
steve-ng / nginx.conf
Last active May 28, 2024 08:27
Nginx reverse proxy wss with ssl
server {
listen 443 ssl;
server_name xxx.xx.io
ssl on;
ssl_certificate /etc/asterisk/certs/xxx.io.pem;
ssl_certificate_key /etc/asterisk/certs/xxx.io.key;
ssl_session_timeout 5m;
source "https://rubygems.org"
gem 'eventmachine'
gem 'rubysl-stringio'
gem 'sinatra'
gem 'yajl-ruby', require: 'yajl'
gem 'thin'
gem 'em-websocket', :git=>'https://github.com/igrigorik/em-websocket.git'
@sebmarkbage
sebmarkbage / Enhance.js
Last active February 10, 2025 06:23
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@staltz
staltz / index.ios.js
Created April 7, 2015 06:43
Experiment with Cycle.js and React Native
'use strict';
var React = require('react-native');
var Cycle = require('cyclejs');
var {Rx, h} = Cycle;
var createExperimentalIOSRenderer = require('./src/ios-renderer.ios.js');
var {StyleSheet, Text, TextInput, View} = React;
var styles = StyleSheet.create({
container: {
@jackiewu
jackiewu / Rotating 3D Slider.markdown
Created August 1, 2015 04:01
Rotating 3D Slider

Rotating 3D Slider

Sourse of inspiration - http://rdcm.com/en/

Slider not working in IE, because of transform-style: preserve-3d. Handle control is broken in FF during rotation, because FF still have this nasty bug with stacking context and translateZ, and it's simply breaks z-index order for elements.

I tried to create this slider as sort of plugin/component. It's more like a practice, so js architecture is pretty random. But it's working :) And you can use multiple sliders on page with different sizes and different settings (you can find options object in js).

Don't forget to rotate slides with control handle.

@notpeelz
notpeelz / veracrypt_mount.sh
Last active September 27, 2016 15:28
VeraCrypt volume (secure) mounting via GUI
#!/bin/bash
DEVICE=/dev/sda1
IMAGE_PATH='/media/$1/Storage/.veracrypt/volume'
MOUNT_PATH='/mnt/volume'
if [[ "$USER" != "root" ]]; then
gvfs-mount -d $DEVICE
gksu -D $(basename $0) $0 $USER
exit $?