Skip to content

Instantly share code, notes, and snippets.

View ninetwentyfour's full-sized avatar

Travis Berry ninetwentyfour

View GitHub Profile
@ninetwentyfour
ninetwentyfour / example1.php
Last active June 5, 2022 08:40
Use PHP To Zip Folders For Download - blogpost
<?php
// WARNING
// This code should NOT be used as is. It is vulnerable to path traversal. https://www.owasp.org/index.php/Path_Traversal
// You should sanitize $_GET['directtozip']
// For tips to get started see http://stackoverflow.com/questions/4205141/preventing-directory-traversal-in-php-but-allowing-paths
//Get the directory to zip
$filename_no_ext= $_GET['directtozip'];
// we deliver a zip file
sponsoredItems = []
for i in data.xpath('ffed_item)
sponsored = i.xpath("div/span[@class='label--sponsored']")
if sponsored is not None:
sponsoredItems = sponsoredItems.append(i)
print(sponsoredItems)
@ninetwentyfour
ninetwentyfour / example1.php
Created August 28, 2011 19:02
Upload Videos To MediaSilo With PHP/FTP - blogpost
<?php
//MediaSilo Information
$server = "upload.mediasilo.com";
$ftp_user_name = "YOUR MEDIASILO LOGIN NAME AND HOSTNAME(e.g NAMEHOSTNAME";
$ftp_user_pass = "YOUR MEDIASILO LOGIN PASSWORD";
$dest = "THE WORKSPACE YOU WANT TO UPLOAD TO";
//Video Folder Information
$source_folder = "FULL PATH TO FOLDER. NO TRAILING SLASH (e.g. /var/www/videofolder)";
//Grabs everything in the source folder. You may want to set a file type like, ($source_folder."/*.flv")
require 'sendgrid-ruby'
include SendGrid
require 'json'
html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title></title></head><body>
<div>
<br>
<%CONTACT_SYNC_HASH%>
@ninetwentyfour
ninetwentyfour / gist:990112
Created May 25, 2011 01:01
Zip Folder PHP
<?php
//Get the directory to zip
$filename_no_ext= $_GET['directtozip'];
// we deliver a zip file
header("Content-Type: archive/zip");
// filename for the browser to save the zip file
header("Content-Disposition: attachment; filename=$filename_no_ext".".zip");
@ninetwentyfour
ninetwentyfour / example1.php
Created August 28, 2011 16:39
Use WordPress’ is_page() To Display Custom Content - blogpost
<?php
if ( is_page('about')) {
echo '<div id="secondnav">This is the super cool secondary navigation.</div>';
}
?>
@ninetwentyfour
ninetwentyfour / documents_controller.rb
Last active December 12, 2015 01:58
Simple Multi-File Uploads With Paperclip
params[:document][:filearrays].each do |file|
@document = Document.new(:document => file)
@document.save
end
@ninetwentyfour
ninetwentyfour / homebrew-update.sh
Created September 16, 2012 00:54 — forked from douglasjarquin/homebrew-update.sh
Update outdated Homebrew packages
brew upgrade `brew outdated | awk {'print $1'} | xargs`
@ninetwentyfour
ninetwentyfour / projects_controller.php
Created April 8, 2012 18:58
IndexTank To IndexDen
<?php
function add_to_index() {
$projects = $this->Project->find('all');
foreach($projects as $project){
$indexData = array('text'=>$project['Project']['title'],'title'=>$project['Project']['title'],'description'=>$project['Project']['description'],'user_id'=>$project['Project']['user_id']);
$id = $project['Project']['_id'];
$this->addIndextank("HomkoraProjects",$id,$indexData);
@ninetwentyfour
ninetwentyfour / application.html.erb
Created April 7, 2012 18:37
Real Time In Place Editing For Rails - blogpost
<script src="http://your-juggernaut-app.herokuapp.com/application.js" type="text/javascript" charset="utf-8"></script>