Skip to content

Instantly share code, notes, and snippets.

View stefanbc's full-sized avatar
🖖
Do; or do not. There is no // TODO

Stefan Cosma stefanbc

🖖
Do; or do not. There is no // TODO
View GitHub Profile
@stefanbc
stefanbc / wp_reset.php
Created January 21, 2014 07:15
WordPress reset Install
<?php
// HOW TO USE:
// Simply type in the url in the text box to reset the WordPress site url.
// WARNING:
// This file can be a HUGE security risk and has the potential to seriously
// mess up your site's database. Please use with caution and DELETE THIS FILE when you
// are done resetting your website.
@stefanbc
stefanbc / getCoordinates.php
Created June 13, 2013 22:06
Get coordinates for a specified address
<?php
// Get coordinates for a specified address
function getCoordinates($address){
$address = str_replace(" ", "+", $address); // replcae all the white space with "+" sign to match with google search pattern
$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";
$response = file_get_contents($url);
@stefanbc
stefanbc / svn_client.bat
Created June 13, 2013 17:35
SVN bat file
@echo off
title SVN Client v1.0
echo ####################################
echo ## ##
echo ## Welcome to the SVN Client v1.0 ##
echo ## ##
echo ####################################
cd C:\Program Files\SlikSvn\bin\
@stefanbc
stefanbc / custom.js
Created May 9, 2013 19:30
Change select box options dynamically
// Change select box options based on value from another select box
$(document).ready(function(){
// If the user select a value from the select
$('#FIRST_SELECT').change(function(){
// Get the selected value
var get_eveniment = $(this).val();
@stefanbc
stefanbc / cron.php
Created May 9, 2013 10:38
Wordpress Cron Job
<?
echo '<h1>DirectAdmin</h1>';
echo '<i>php -q /home/DIRECTADMIN_USERNAME/domains/DOMAIN/public_html/wp-cron.php</i>';
echo '<hr>';
echo '<h1>cPanel</h1>';
echo '<i>php -q /home/CPANEL_USERNAME/public_html/wp-cron.php</i>';
@stefanbc
stefanbc / roles.php
Created April 4, 2013 11:48
Remove any Wordpress user role
<?php
require_once 'wp-load.php';
$wp_roles = new WP_Roles();
$wp_roles->remove_role("YOUR_ROLE"); // author, editor, contributor
$names = $wp_roles->get_names();
print_r($names);
?>
@stefanbc
stefanbc / mail.php
Created April 4, 2013 10:34
HTML wp_mail() with attachments
<?php
$headers = "MIME-Version: 1.0\r\n";
$headers .= 'From: ' . get_bloginfo('admin_email') . "\r\n";
$headers .= "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
$receiver = get_user_by('id', $receiver_id);
$giver = get_user_by('id', $giver_id);
$to = $receiver->user_email;
$subject = 'Subject';
@stefanbc
stefanbc / Headers
Created March 25, 2013 11:17
Cross Domain Ajax
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
?>
@stefanbc
stefanbc / Wordpress to Jekyll
Created January 8, 2013 20:19
If you need to migrate your blog from Wordpress to Jekyll there is a PHP code for it.
<?php
// This is the script I used to export my old blog out of WordPress and into a
// Jekyll friendly format. The first half exports posts, the second does pages.
// It's fairly specific to my needs, but maybe it'll be a good starting point
// for you. /RTH 2011-08-28
// https://twitter.com/#!/marcoarment/status/59089853433921537
date_default_timezone_set('America/Los_Angeles');
$db = mysql_connect('host', 'username', 'pass') or die(mysql_error());
@stefanbc
stefanbc / README.md
Last active August 29, 2015 14:07 — forked from addyosmani/README.md
CSS Layout Debugger

CSS Layout Debbuger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version