Skip to content

Instantly share code, notes, and snippets.

@ryanwinchester
ryanwinchester / bitwise.php
Last active August 15, 2023 05:16
BITWISE FLAGS for Custom PHP Objects
<?php
/**
* BITWISE FLAGS for Custom PHP Objects
*
* @link http://php.net/manual/en/language.operators.bitwise.php#108679
*
* Sometimes I need a custom PHP Object that holds several boolean TRUE or FALSE values.
* I could easily include a variable for each of them, but as always, code has a way to
* get unweildy pretty fast. A more intelligent approach always seems to be the answer,
KEYBINDINGS
byobu keybindings can be user defined in /usr/share/byobu/keybindings/ (or within .screenrc if byobu-export was used). The common key bindings
are:
F2 - Create a new window
F3 - Move to previous window
F4 - Move to next window
@johnpolacek
johnpolacek / .gitconfig
Last active March 22, 2024 05:51
My current .gitconfig aliases
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
aa = add -A .
@milo
milo / github-webhook-handler.php
Last active July 26, 2023 15:29
GitHub Webhook Handler
<?php
/**
* GitHub webhook handler template.
*
* @see https://docs.github.com/webhooks/
* @author Miloslav Hůla (https://github.com/milo)
*/
$hookSecret = 's.e.c.r.e.t'; # set NULL to disable check
@tomhemsley
tomhemsley / gist:e985db339da947fa035d
Created August 5, 2014 12:33
Meta Slider Change Capability / User Role Editor
/**
* The default capability required to use Meta Slider is 'edit_others_posts'.
* You can change this to a different capability by pasting the code below into
* your themes functions.php file.
*
* You can use the 'User Role Editor' plugin to add a custom capability to WordPress
* specifically for Meta Slider users.
*/
function metaslider_change_required_role($capability) {
return 'metaslider_use'; // this is the ID of a custom capability added using User Role Editor
@staltz
staltz / introrx.md
Last active April 19, 2024 09:27
The introduction to Reactive Programming you've been missing
@danharper
danharper / background.js
Last active March 30, 2024 18:25
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@xeoncross
xeoncross / composer.md
Last active March 26, 2024 02:59
How composer actually works

Composer

the missing quick-start guide

We will assume we have a package/project called https://github.com/foo/bar

Most redistributable packages are hosted on a version control website such as Github or Bitbucket. Version control repositories often have a tagging system where we can define stable versions of our application. For example with git we can use the command:

git tag -a 1.0.0 -m 'First version.'

With this we have created version 1.0.0 of our application. This is a stable release which people can depend on. If we wanted to include "foo/bar" then we could create a composer.json and specify the tagged release we wanted:

@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active March 15, 2024 11:26
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@bamanzi
bamanzi / zsh-git-prompt.sh
Created June 27, 2013 09:43
zsh: show git repo name, branch in right prompt
# although StackOverflow has this answer http://stackoverflow.com/a/1128583
# but that code is unreadable, thus I have this (also based on a SO anower: http://stackoverflow.com/a/1128721 )
# get the name of the branch we are on
_git_repo_name() {
gittopdir=$(git rev-parse --git-dir 2> /dev/null)
if [[ "foo$gittopdir" == "foo.git" ]]; then
echo `basename $(pwd)`
elif [[ "foo$gittopdir" != "foo" ]]; then
echo `dirname $gittopdir | xargs basename`