Skip to content

Instantly share code, notes, and snippets.

View gegere's full-sized avatar

Jason Gegere gegere

View GitHub Profile
@gegere
gegere / db_session.php
Created February 4, 2011 01:51
This is used to properly stored multiple session objects to the database. This code was enhanced a little from the PHP5 Advanced Book
<?php
// Define the open_session() function:
// This function takes no arguments.
// This function should open the database connection.
function open_session() {
global $dbconn;
// Connect to the database.
$dbconn = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Cannot connect to the database.');
@gegere
gegere / autofollow.php
Created June 24, 2012 18:36 — forked from 0xnbk/autofollow.php
Twitter autofollow script (PHP)
<?php
// Twitter Auto-follow Script by Dave Stevens - http://davestevens.co.uk
$user = "";
$pass = "";
$term = "";
$userApiUrl = "http://twitter.com/statuses/friends.json";
@gegere
gegere / gist:3162221
Created July 23, 2012 06:15
2-Way Encryption Scheme
class Encryption
{
public function encrypt($plaintext,$key)
{
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
$crypttext = mcrypt_generic($td, $plaintext);
mcrypt_generic_deinit($td);
return base64_encode($iv.$crypttext);
@gegere
gegere / gist:3220993
Created July 31, 2012 21:54 — forked from boucher/gist:1750375
Stripe PHP simple example
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("YOUR-API-KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
@gegere
gegere / README.md
Last active November 8, 2019 01:10 — forked from oodavid/README.md
Used for automatically deploying websites via github or bitbucket

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@gegere
gegere / twitter.class.inc.php
Last active December 11, 2015 01:49
Would you like to display your recent tweets? This PHP class will help you get this job done. This class uses the JSON format.
<?php
class RecentTweets{
private $username;
const cache = '/cache/';
public function __construct($username){
$this->username = $username;
}
<?php
class tweet_scroll {
/******************************************************************
** database access constants **
** edit these **
******************************************************************/
private $dbName = 'YOUR MYSQL DATABASE NAME';
private $dbHost = 'YOUR MYSQL DATABASE HOST';
private $dbUser = 'YOUR MYSQL DATABASE USERNAME';
@gegere
gegere / credit_card_helper.php
Created September 19, 2013 02:46
The CodeIgniter Helper handles many credit card checks which can be used to manipulate credit card numbers and related information
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Credit Card Functions
*
* This helper module contains functions which can be used to manipulate credit
* card numbers and related information.
*
* @package CodeIgniter
@gegere
gegere / cheap_rsync.sh
Created September 19, 2013 05:36
This is the cheapest of cheapo you will find for a script that performs remote backups using simply rsync, a destination host, and a directory on that destination host to store the backups.
#!/bin/bash
#
# Cheap Rsync System for Remote Backups
#
# This is the cheapest of cheapo you will find for a script
# that performs remote backups using simply rsync, a destination
# host, and a directory on that destination host to store the backups.
#
# Author: Jason Gegere
# Date: 11-21-2006, 9:29AM CST
@gegere
gegere / gist:73c069ef2c9e9845a3c8
Created December 16, 2014 23:44
Helpful logs around the time of etcd failures...
Dec 14 08:42:04 coreos63.htmlgraphic.com fleetd[14289]: INFO manager.go:89: Triggered systemd unit mysqld.service stop: job=999801
Dec 14 08:42:04 coreos63.htmlgraphic.com fleetd[14289]: INFO manager.go:231: Removing systemd unit mysqld.service
Dec 14 08:42:04 coreos63.htmlgraphic.com fleetd[14289]: INFO manager.go:142: Instructing systemd to reload units
Dec 14 08:42:04 coreos63.htmlgraphic.com fleetd[14289]: INFO reconcile.go:274: AgentReconciler completed task: type=UnloadUnit job=mysqld.service reason="unit loaded but not sche
Dec 14 08:42:09 coreos63.htmlgraphic.com fleetd[14289]: INFO manager.go:89: Triggered systemd unit mysqld-discovery.service stop: job=999805
Dec 14 08:42:09 coreos63.htmlgraphic.com fleetd[14289]: INFO manager.go:231: Removing systemd unit mysqld-discovery.service
Dec 14 08:42:09 coreos63.htmlgraphic.com fleetd[14289]: INFO manager.go:142: Instructing systemd to reload units
Dec 14 08:42:09 coreos63.htmlgraphic.com fleetd[14289]: INFO reconcile.go:274: AgentReconciler completed task