Skip to content

Instantly share code, notes, and snippets.

import random
def main():
# create array of 500 elements
nums=[0]*500
# populate each array element with a random int from 0-100
for i in range(len(nums)):
nums[i]=random.randint(0, 100)
total=getTotal(nums)
@pfeilbr
pfeilbr / customerLogin.php
Created June 9, 2014 13:01
login handler
<?php
$loggedin = false;
$error = false;
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$userName=addslashes($_POST['userName']);
$userPwd=addslashes($_POST['userPwd']);
$sql="SELECT * FROM users WHERE userName='$userName' and userPwd='$userPwd'";
$result=mysql_query($sql);
@pfeilbr
pfeilbr / node-os-module-playground.js
Created October 20, 2014 15:17
node OS module playground
var os = require('os');
var methodNames = [];
for (var prop in os) {
if ( os.hasOwnProperty(prop) && typeof os[prop] === 'function') {
methodNames.push(prop)
}
}
@pfeilbr
pfeilbr / loadAndPlaySounds.swift
Created January 12, 2015 20:31
example of loading and laying sound files (.wav) from directory in app bundle
import AudioToolbox
func loadAndPlaySounds() {
var path = NSBundle.mainBundle().bundlePath.stringByAppendingPathComponent("sounds")
if let fileNames = NSFileManager.defaultManager().contentsOfDirectoryAtPath(path, error: nil) as? [String] {
for fileName in fileNames {
var filePath = path.stringByAppendingPathComponent(fileName)
println("filePath = \(filePath)")
class NonMatchedAccountExporter {
public void run(List_MRK__c listID) {
Boolean moreToProcess = execute(listID);
while(moreToProcess = true) {
moreToProcess = execute(listID);
}
}
public Boolean execute(List_MRK__c listID) {
@pfeilbr
pfeilbr / Adobe AIR HTML Control <-> JavaScript Communication Example
Created March 20, 2010 10:06
Adobe AIR HTML Control <-> JavaScript Communication Example
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:HTML left="10" top="10" bottom="10" right="10" id="html"/>
<mx:Script>
<![CDATA[
private function init():void {
html.addEventListener(Event.COMPLETE, this.htmlComplete);
html.htmlText = Helper.html();
}
@pfeilbr
pfeilbr / horizontally & vertically center div in containing div
Created May 21, 2010 02:10
horizontally & vertically center div in containing div
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Brian Pfeil">
<!-- Date: 2010-05-20 -->
{
"id": "8d98e250-5e11-11e5-8d11-8912d003bf4f",
"complete": true,
"operation": "open-project",
"error": "Cannot read property 'path' of undefined",
"stack": "TypeError: Cannot read property 'path' of undefined\n at /Applications/MavensMate.app/Contents/Resources/app/node_modules/mavensmate/lib/mavensmate/commands/project/open-project.js:36:40\n at tryCatch2 (/Applications/MavensMate.app/Contents/Resources/app/node_modules/mavensmate/node_modules/bluebird/js/main/util.js:53:21)\n at Promise._resolveFromResolver (/Applications/MavensMate.app/Contents/Resources/app/node_modules/mavensmate/node_modules/bluebird/js/main/promise.js:544:13)\n at new Promise (/Applications/MavensMate.app/Contents/Resources/app/node_modules/mavensmate/node_modules/bluebird/js/main/promise.js:82:37)\n at Command.execute (/Applications/MavensMate.app/Contents/Resources/app/node_modules/mavensmate/lib/mavensmate/commands/project/open-project.js:25:10)\n at /Applications/MavensMate.app/Contents/Resources/app/no
@pfeilbr
pfeilbr / dynamic-web-font-sizes.html
Created September 28, 2011 17:56
Dynamic Web Font Sizes
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Brian Pfeil">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
@pfeilbr
pfeilbr / example.js
Created February 12, 2012 19:57
Patch to forcetk.js to login & apexrest methods. add login via username & password with a grant_type of password to eliminate the Oauth redirect process
var c = new forcetk.Client('<client_id>');
c.login({
'environment': 'test',
'client_id': '<client_id>',
'client_secret': '<client_secret>',
'username': 'joe@example.com',
'password': 'secret123'
}, function(data) {