Skip to content

Instantly share code, notes, and snippets.

View acidtib's full-sized avatar

Dainel Vera acidtib

View GitHub Profile
@acidtib
acidtib / status.php
Created February 19, 2012 21:32
Check if wow server is running
<?php
$host = '173.192.81.52';
$ports = array(8085);
foreach ($ports as $port)
{
    $connection = @fsockopen($host, $port);
    if (is_resource($connection))
@acidtib
acidtib / gist:1881639
Created February 22, 2012 05:16
pull workers
<?php
$string = file_get_contents("https://www.bitlc.net/api/user_data/a5J5hCfN3jmJ4fumx8jD");
echo '<div style="display: none;"> '.$string.' </div>';
$json_a=json_decode($string,true);
// array method
foreach($json_a[workers] as $w)
@acidtib
acidtib / gist:2437060
Created April 21, 2012 13:18
execute sql query
// execute sql query //
$query = sprintf( 'SELECT p.productid, p.prodcode AS "Handle", p.prodname AS "Title", p.proddesc AS "Body (HTML)", p.upc AS "Vendor", p.upc AS "Type", p.upc AS "Tags", p.upc AS "Option1 Name", p.upc AS "Option1 Value", p.upc AS "Option2 Name", p.upc AS "Option2 Value", p.upc AS "Option3 Name", p.upc AS "Option3 Value", p.prodcode AS "Variant SKU", p.upc AS "Variant Grams", p.upc AS "Variant Inventory Tracker", p.upc AS "Variant Inventory Qty", p.upc AS "Variant Inventory Policy", p.upc AS "Variant Fulfillment Service", p.prodprice AS "Variant Price", p.upc AS "Variant Requires Shipping", p.upc AS "Variant Taxable", p.upc AS "Image Src", i.imagefile AS "Image Src" FROM isc_products p, isc_product_images i WHERE prodcatids = "37" AND p.productid=i.imageprodid' );
$result = mysql_query( $query, $conn ) or die( mysql_error( $conn ) );
@acidtib
acidtib / ffmpeg.rb
Created May 10, 2012 01:34 — forked from Flamefork/ffmpeg.rb
ffmpeg & carrierwave
module CarrierWave
module FFMPEG
extend ActiveSupport::Concern
module ClassMethods
def faststart
process :faststart => true
end
def transcode options
array(8) {
[0]=>
array(3) {
["type"]=>
string(10) "video/webm"
["quality"]=>
string(5) "hd720"
["url"]=>
string(511) "http://o-o.preferred.mia05s03.v21.lscache2.c.youtube.com/videoplayback?upn=6hD2p51qbMs&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&fexp=907335%2C919306%2C913539&itag=45&ip=108.0.0.0&signature=A7F644F3DDE4B91560292A013CAC2D8D04EA913C.9C9DCE09E0F36C30ACDE130FED5722181ED3F59B&sver=3&ratebypass=yes&source=youtube&expire=1336649361&key=yt1&ipbits=8&cp=U0hSS1ZPV19LS0NOMl9OSUFEOlA5YkZlRVRBSlFw&id=8b78e87639c656b0&quality=hd720&fallback_host=tc.v21.cache2.c.youtube.com&type=video/webm"
<?php
if(get_field('powered_by'))
{
echo '<h4>Powered By</h4>';
echo '<div class="mamaGata">';
while(the_repeater_field('powered_by'))
{
echo '<div class="gato">';
@acidtib
acidtib / gist:3178153
Created July 25, 2012 19:42
Detect if mobile
<?php
if (count($_GET) > 0) {
$view = $_GET['view'];
} else {
$agent = $_SERVER['HTTP_USER_AGENT'];
if(preg_match('/iPhone|Android|Blackberry/i', $agent)){
header("Location: http://mobil_site.com/");
exit;
@acidtib
acidtib / controller.rb
Created August 8, 2012 16:44 — forked from thomasv314/controller.rb
Multi File Upload with Rails 3 & PaperClip & jQuery
class ArtistsController < ApplicationController
def create_bid
#this is where we delete the images array so that we can
#add them to the model separately afterwards
bids = params[:art_bid].delete(:bid_images)
@artist = Artist.find(params[:id])
@art_bid = ArtBid.new(params[:art_bid])
@acidtib
acidtib / gist:3489675
Created August 27, 2012 15:45
explore
def explore
@states = State.find(params[:id])
@towns = @states.towns.find_all
@postcards = @states.postcards.limit(1)
@towns.each do |t|
postcard = t.postcards.last
end
end
@acidtib
acidtib / gist:3489766
Created August 27, 2012 15:56
explore view
<% @towns.each do |town| %>
<div>
<%= town.town %>
<% @postcards.each do |postcard| %>
<%= postcard.eat %>
<% end %>