Skip to content

Instantly share code, notes, and snippets.

View yesidays's full-sized avatar
🎯
Focusing

Yesi yesidays

🎯
Focusing
View GitHub Profile
@yesidays
yesidays / binary.pl
Created January 15, 2012 04:55
code.jobs - Binary tree - Prolog
% Displaying a binary tree.
% show( Tree): display binary tree
show( Tree) :-
show2( Tree, 0).
% show2( Tree, Indent): display Tree indented by Indent
show2( nil, _).
@yesidays
yesidays / puts3.php
Created January 15, 2012 05:37
code.jobs - Put S3 Bucket - Codeigniter
<?php
function _puts3($filename,$type)
{
$bucketfolder = 'full';
$file = "/home/silvercorp/webapps/codejobs/tmp/".$filename;
$bucket = "silvercorp";
$uri = $bucketfolder.'/'.$filename;
$put = S3::putObject(S3::inputFile($file), $bucket, $uri, S3::ACL_PUBLIC_READ, array(), array("Cache-Control" => "max-age=315360000","Expires" => gmdate("D, d M Y H:i:s T", strtotime("+5 years"))) );
if(!$put) {
@yesidays
yesidays / postwall.php
Created January 15, 2012 05:47
code.jobs - Post wall Facebook - Codeigniter
<?php
function postwall($publishdata)
{
$CI =& get_instance();
$CI->curl->create("https://graph.facebook.com/".$publishdata['uid']."/feed");
$CI->curl->option('buffersize', 10);
$wallpost = array(
'access_token'=> $publishdata['access_token'],
'message' => $publishdata['message'],
'link' => $publishdata['link'],
@yesidays
yesidays / random.php
Created January 17, 2012 01:51
code.jobs - Hexadecimal random color - PHP
<?php
function randomColor() {
$str = '#';
for($i = 0 ; $i < 6 ; $i++) {
$randNum = rand(0 , 15);
switch ($randNum) {
case 10: $randNum = 'A'; break;
case 11: $randNum = 'B'; break;
case 12: $randNum = 'C'; break;
@yesidays
yesidays / .htaccess
Created January 17, 2012 01:55
code.jobs - Delete www on URL - Codeigniter
RewriteEngine On
RewriteCond% {} HTTP_HOST! ^ su-site.com $ [NC]
RewriteRule ^(.*)$ http://your-site.com/ $ 1 [L, R = 301]
@yesidays
yesidays / search.php
Created January 22, 2012 18:21
code.jobs - Search terms with Twitter - Codeigniter
<?php
function search($term) {
$CI =& get_instance();
date_default_timezone_set("America/Mexico_City");
$limit = 25;
$searchresults = $CI->curl->simple_get("http://search.twitter.com/search.json?q='%40$term'&rpp=$limit");
$searcharray = json_decode($searchresults, true);
foreach ($searcharray['results'] as $row)
{
if (array_key_exists("from_user",$row)) {
@yesidays
yesidays / display.cpp
Created January 24, 2012 02:16
code.jobs - Imprimiendo números y letras en display de 7 segmentos - C
#include <stdio.h>
#include <conio.h>
int main(void){
int i,j;
int x[]={6,91,79,102,109,124,7,127,103,63};
int y[]={119,124,57,94,121,113,125,118,6,14,56,63,115,109,62,110};
clrscr();
printf("Imprimiendo numeros\n");
for (j=0;j<=9;j++){
@yesidays
yesidays / oauth.php
Created February 8, 2012 05:10
codejobs - OAuth Twitter - Codeigniter
<?php
function auth()
{
$tokens = $this->tweet->get_tokens();
$user = $this->tweet->call('get', 'account/verify_credentials');
var_dump($user);
$friendship = $this->tweet->call('get', 'friendships/show', array('source_screen_name' => $user->screen_name, 'target_screen_name' => 'silvercorp'));
var_dump($friendship);
@yesidays
yesidays / grafica.php
Created February 8, 2012 05:42
codejobs.biz - Grafica de pastel - Codeigniter
<?php
function pie() {
$this->load->library('phpgraphlib');
$this->load->library('phpgraphlibpie');
$graph = new PHPGraphLibPie(330, 240);
var $data = array(); //Lo llenan con json, xml, mysql, etc
$graph->addData($data);
//El name lo obtienen de alguna consulta
$graph->setTitle('Menciones por #Hashtag : '.utf8_decode($name).'');
$graph->setTextColor("blue");
@yesidays
yesidays / barras.php
Created February 8, 2012 05:49
codejobs.biz - Grafica de barras - Codeigniter
<?php
function barras() {
$this->load->library('phpgraphlib');
$graph = new PHPGraphLib(350,200);
for ($j=1;$j<=$total;$j++) {
$graph->addData($data[$j]);
}
$graph->setBars(false);
$graph->setLine(true);