Skip to content

Instantly share code, notes, and snippets.

View 4gray's full-sized avatar
:octocat:
Focusing

4gray

:octocat:
Focusing
View GitHub Profile
@4gray
4gray / git-tag-delete-local-and-remote.sh
Created August 23, 2019 11:53 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@4gray
4gray / fileSize.ts
Created July 31, 2018 10:03 — forked from Solomko2/fileSize.ts
fileSize pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'fileSize'
})
export class FileSizePipe implements PipeTransform {
private units = [
'bytes',
'KB',
<div ng-class="condition ? 'class-if-true' : 'class-if-false'">
@4gray
4gray / ID.js
Created March 2, 2017 15:26
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@4gray
4gray / lightbox.rb
Created July 23, 2016 11:28 — forked from melborne/lightbox.rb
Jekyll Lightbox Image Plugin
# A Liquid tag for Jekyll sites that allows embedding Lightbox images.
# by: kyoendo
# Source URL: https://gist.github.com/4035604
#
# Example usage: {% lightbox 2012/abc.png, Title of Image, Alt Title %}
module Jekyll
class LightboxTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

<?php
add_action('admin_menu', 'plugin_admin_add_page');
function plugin_admin_add_page() {
//http://codex.wordpress.org/Function_Reference/add_menu_page
add_menu_page( 'custom menu title', 'custom menu', 'manage_options', 'dbexplorer/adminpage.php');
}
function my_enqueue($hook) {
//only for our special plugin admin page
if( 'dbexplorer/adminpage.php' != $hook )
<?php
add_action('admin_menu', 'plugin_admin_add_page');
function plugin_admin_add_page() {
add_options_page('Custom Plugin Page', 'Custom Plugin Options Page', 'manage_options', 'page_slug', 'plugin_options_page'); //settings menu page
}
function plugin_options_page() {
//HTML and PHP for Plugin Admin Page
echo "<h2>The Custom Plugin Options Page</h2>";
}
/**
* Programmatically logs a user in
*
* @param string $username
* @return bool True if the login was successful; false if it wasn't
*/
function programmatic_login( $username ) {
if ( is_user_logged_in() ) {
wp_logout();
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
//Title and subtitle
toolbar.setTitle("MY toolbar");
toolbar.setSubtitle("Subtitle");
//Menu
toolbar.inflateMenu(R.menu.toolbar_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {