Skip to content

Instantly share code, notes, and snippets.

@premek
premek / mv.sh
Last active Sep 30, 2020
Rename files in linux / bash using mv command without typing the full name two times
View mv.sh
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@benhurott
benhurott / AndroidCheckNotificationIsEnabled.java
Created Nov 16, 2016
React Native : Android : Check notification is enabled
View AndroidCheckNotificationIsEnabled.java
@ReactMethod
public void areNotificationsEnabled(Promise promise) {
try {
Boolean areEnabled = NotificationManagerCompat.from(getReactApplicationContext()).areNotificationsEnabled();
promise.resolve(areEnabled);
}catch (Exception e) {
promise.reject(e);
}
}
@dstreet
dstreet / next-hoc.js
Last active Oct 21, 2020
Example HOC with Next.js
View next-hoc.js
import React from 'react'
/*
* Higher order component that passes `getInitialProps` through
* to the child component
*/
const HOC = function(Child) {
return class Higher extends React.Component {
static getInitialProps(ctx) {
return Child.getInitialProps(ctx)
@gblmarquez
gblmarquez / .tmux.conf
Created Aug 6, 2015
.tmux.conf with fish as default shell
View .tmux.conf
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# support logging out and back in
set -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION"
# pbcopy support
set-option -g default-command "reattach-to-user-namespace -l bash"
# vi mode
View gist:b40e49e19b1e1c2fe042
To circle.yml:
dependencies:
post:
- bin/cisetup
checkout:
post:
- git fetch origin --depth=1000000
@claviska
claviska / vertically-centered-bootstrap-modals.js
Last active May 15, 2020
Vertically Centered Bootstrap Modals
View vertically-centered-bootstrap-modals.js
/**
* Vertically center Bootstrap 3 modals so they aren't always stuck at the top
*/
$(function() {
function reposition() {
var modal = $(this),
dialog = modal.find('.modal-dialog');
View local-dnsserver.md

Setting up a local DNS server with bind on OSX Mavericks

This is really just an approach for locally testing DNS changes, which can easily be done with a HOSTS file if the change involves an IP address, but gets a bit trickier when things like CNAMEs are involved. This is only meant to test locally off a single machine.

  1. Install bind using homebrew

    brew install bind

  2. Follow the installation steps to start up bind

@staltz
staltz / introrx.md
Last active Nov 27, 2020
The introduction to Reactive Programming you've been missing
View introrx.md
@chrisjlee
chrisjlee / gulpfile.js
Last active Jan 6, 2016
Gulp + jekyll + sass + connect + livereload
View gulpfile.js
var gulp = require('gulp'),
concat = require('gulp-concat'),
sass = require ('gulp-ruby-sass'),
autoprefixer = require ('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
jekyll = require('gulp-jekyll'),
// livereload = require('gulp-livereload'),
watch = require('gulp-watch'),
jshint = require("gulp-jshint"),
View asset_sync_is_the_devil.md

A not politically correct assertion of my feelings towards a piece of software:

Note: Repetition builds cynicism, asset_sync isn't bad, but when an asset problem cannot be solved via support it gets escalated to me. Often times someone using asset_sync the problem is due to their use of the library and not from Heroku.

Backstory

The asset sync gem uploads your assets (images, css, javascript) to S3. From there you can either point browsers to the copy on S3 or use a CDN + the S3 bucket. It's a good idea, and solved a problem at one time.

It is no longer needed and you should now use https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn instead. So rather than copying your assets over to S3 after they are precompiled the CDN grabs them from your website instead. Here's some reasons why it's better.

You can’t perform that action at this time.