Skip to content

Instantly share code, notes, and snippets.

@0xnbk
0xnbk / twitter.php
Created November 5, 2010 10:57 — forked from abraham/twitter.php
How to tweet with OAuth in three lines
<?php
// Download the latest version of TwitterOAuth from http://github.com/abraham/twitteroauth/downloads
// Unpack the download and place the twitteroauth.php and OAuth.php files in the same directory as this file.
// Register an application at http://dev.twitter.com/apps and from your new apps page get "my access token".
require_once('twitteroauth.php');
$connection = new TwitterOAuth('app consumer key', 'app consumer secret', 'my access token', 'my access token secret');
$connection->post('statuses/update', array('status' => 'text to be tweeted'));
@0xnbk
0xnbk / .js
Created October 19, 2010 04:59
Changing Javascript Alert Button Text (For jQuery + jConfirm)
$.alerts.okButton="OKAYYYYYYYYYY";
$.alerts.cancelButton="CANCELLLLLLLLLL";
@0xnbk
0xnbk / .php
Created October 8, 2010 04:56
File download with speed limit
<?php
// local file that should be send to the client
$local_file = 'test-file.zip';
// filename that the user gets as default
$download_file = 'your-download-name.zip';
// set the download rate limit (=> 20,5 kb/s)
$download_rate = 20.5;
if(file_exists($local_file) && is_file($local_file)) {
// send headers
@0xnbk
0xnbk / .php
Created October 7, 2010 03:38
PHP code to query goo.gl to shorten an url ( your php api for google url shortening )
<?php
// uses Google's http://goo.gl/ URL shortener
/* Enter your url below */
$url = "aroundtheweb.info";
/* Function to get the short url */
function get_short_url($url) {
$ch = curl_init("http://goo.gl/api/url?url=" . urlencode($url));
curl_setopt($ch, CURLOPT_POST ,1);
@0xnbk
0xnbk / .css
Created October 6, 2010 04:30
Remove Scrollbar from Textarea in IE
textarea { overflow: auto; }
@0xnbk
0xnbk / .php
Created September 29, 2010 05:26
Force browser to download file instead of displaying (pdf, doc, docx, odt etc)
<?php
// place this code inside a php file and call it f.e. "download.php"
$path = $_SERVER['DOCUMENT_ROOT']."/path2file/"; // change the path to fit your websites document structure
$fullPath = $path.$_GET['download_file'];
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
@0xnbk
0xnbk / .php
Created September 17, 2010 03:57
Redirect To Page On Your Site, if browser is IE
<?php
//if the browser is Microsoft IE
//if (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT'])) {
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
//if (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT']))
header("Location: your_error_page.php")
}?>
@0xnbk
0xnbk / .php
Created September 17, 2010 03:57
Show IE Warning Message
<?php
//if the browser is Microsoft IE
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
//if (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT']))
echo "Your Error Message Here";
}?>
@0xnbk
0xnbk / culturegridne.1.4.bat
Created September 13, 2010 08:41
Twitter Bot (bat file)
@echo off
rem ==============================
rem test for user input
rem ==============================
if [%1]==[] goto error
if [%2]==[] goto error
rem ==============================
rem set password and user name
rem ==============================
set user=%1
@0xnbk
0xnbk / .php
Created September 13, 2010 08:39
Display your Twitter entries on your WordPress blog
<?php include_once(ABSPATH . WPINC . '/rss.php');
wp_rss('http://twitter.com/statuses/user_timeline/15985955.rss', 5); ?>