Skip to content

Instantly share code, notes, and snippets.

from ftplib import FTP
### Clean up all the mac resource fork files starting with ._ on FTP
def main():
f = FTP('121.199.122.95')
f.login('zsj2q1','e2d7t6c3')
print ('logging in')
clearDir(f,'htdocs')
f.close()
<?php
function elbe_current_user_can($capability, $current_user) {
//replace wp2_ with your database prefix -.-
$roles = get_option('wp2_user_roles');
$user_roles = $current_user->wp_capabilities;
if ($user_roles == null)
return false;
$user_roles = array_keys($user_roles, true);
$role = $user_roles[0];
$capabilities = $roles[$role]['capabilities'];
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.lizdo.ftpbackupweekly.plist</string>
<key>Program</key>
<string>/Users/Liz/Library/Scripts/FTPAutoBackup.php</string>
<key>LowPriorityIO</key>
<true/>
#! /usr/bin/python
### Copy everything on a FTP server to a local folder
from ftplib import FTP
import os.path
import datetime
def main():
#fill in the parameters here
ftpaddress = '1.1.1.1'
<?php
function post_image($post, $targetwidth = 100, $targetheight = 100, $resize = true){
$key="post-image";
$post_image = get_post_meta($post->ID, $key, true);
if ($post_image != null) {
//get image size
$width = get_post_meta($post->ID, "post-image-width", true);
$height = get_post_meta($post->ID, "post-image-height", true);
if ($width == null || $height == null){
//only calculates the size for the first time.
<?php
$style = '';
$userid_array = $wp_user_search->get_results();
foreach ($userid_array as $userid ) {
$user_object = new WP_User($userid);
$roles = $user_object->roles;
$role = array_shift($roles);
$userobject_array[] = $user_object;
}
on idle
tell application "System Events"
tell current location of network preferences
set myConnection to the service "VPN (PPTP)"
if current configuration of myConnection is not connected then
connect myConnection
end if
end tell
return 120
end tell
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *hitView = [super hitTest:point withEvent:event];
if (hitView == self)
//non of my subView's bounds are hit, and I'm transparent
return nil;
else
return hitView;
}
#! /usr/bin/python
### Convert Audio for iPhone Project
import os.path
import subprocess
import shutil
def main():
dir = '/Users/Liz/Dropbox/Projects/BoardGame/Sound'
files = os.listdir(dir)
os.chdir(dir)
@Lizdo
Lizdo / gist:3016359
Created June 29, 2012 06:53 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt