Skip to content

Instantly share code, notes, and snippets.

@uzegonemad
uzegonemad / generate.py
Last active December 21, 2015 11:19
Generate Short URL... It's my first day in Python
from random import choice
from string import (ascii_letters, digits)
def generateLinkSlug(length = 6):
return "".join([choice(ascii_letters + digits) for x in xrange(length)])
print generateLinkSlug()
Process: CloudNotes [94119]
Path: /Applications/CloudNotes.app/Contents/MacOS/CloudNotes
Identifier: com.peterandlinda.CloudNotes
Version: 0.6.4 (9)
Code Type: X86-64 (Native)
Parent Process: launchd [296]
User ID: 501
Date/Time: 2014-03-18 22:38:31.761 -0500
OS Version: Mac OS X 10.8.5 (12F45)
@uzegonemad
uzegonemad / entrust-user-permission.md
Created March 12, 2015 22:15
Entrust Laravel 5 User Permissions

What is this?

Entrust is a fantastic role-based permission library for Laravel. However, by design, it only supports attaching permissions to roles, not to users.

This gist adds support for user-specific permissions on top of existing roles.

There's a chance that this hasn't been thought out fully, so use it at your own risk... I'm offering zero support for this. It either works, or it doesn't.

This has only been tested on Entrust's Laravel 5 branch.

How to use it

@uzegonemad
uzegonemad / removing-related-youtube-videos-from-wordpress-oembeds.php
Last active August 29, 2015 14:18
Removing "Related YouTube Videos" From WordPress oEmbeds
<?php
add_filter('wpbdp_form_field_html_value', 'alter_wpbdp_form_field_html_value', 10, 3);
function alter_wpbdp_form_field_html_value($value, $post_id, $class)
{
// add tel: to phone numbers
if($class->get_id() == 6) // the ID of the field to modify
{
$value = '<a href="tel:'.preg_replace('/[^0-9]/', '', $value).'">'.$value.'</a>';
}
<?php
/**
* Plugin Name: Remove login autocomplete
* Description: Disable login password autocomplete
* Version: 0.1
* Author: Nobody
* License: WTFPL
*/
add_action('login_init', 'acme_autocomplete_login_init');
$root = "C:\Program Files (x86)\Microsoft Games\Halo"
# if sdtm is prefixed, install them
if(Test-Path("$root\Maps-SDTM"))
{
Move-Item "$root\Maps" "$root\Maps-Default"
Move-Item "$root\Maps-SDTM" "$root\Maps"
[System.Windows.Forms.MessageBox]::Show("SDTM Maps Activated")
}
# otherwise install the default
@uzegonemad
uzegonemad / blog-server-maintenance-1.sh
Created April 2, 2015 00:59
blog-server-maintenance
cd /tmp
mysqldump -uroot -p --all-databases > dump.sql
@uzegonemad
uzegonemad / wordpress-drop-down-menus-with-a-custom-walker-1.php
Created April 2, 2015 01:06
wordpress-drop-down-menus-with-a-custom-walker
<?php
class Dropdown_Walker_Nav_Menu extends Walker_Nav_Menu {
function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output) {
$id_field = $this->db_fields['id'];
if(!empty($children_elements[$element->$id_field])) {
$element->classes[] = 'dropdown';
}
Walker_Nav_Menu::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
}