Public
snipts
showing 1-20 of 4467 snipts
-
∞ Stack
using System; using System.Collections; public class SamplesStack { public static void Main() { // Creates and initializes a new Stack. Stack myStack = new Stack(); myStack.Push( "The" ); myStack.Push( "quick" ); myStack.Push( "brown" ); myStack.Push( "fox" ); // Displays the Stack. Console.Write( "Stack values:" ); PrintValues( myStack, '\t' ); // Removes an element from the Stack. Console.WriteLine( "(Pop)\t\t{0}", myStack.Pop() ); // Displays the Stack. Console.Write( "Stack values:" ); PrintValues( myStack, '\t' ); // Removes another element from the Stack. Console.WriteLine( "(Pop)\t\t{0}", myStack.Pop() ); // Displays the Stack. Console.Write( "Stack values:" ); PrintValues( myStack, '\t' ); // Views the first element in the Stack but does not remove it. Console.WriteLine( "(Peek)\t\t{0}", myStack.Peek() ); // Displays the Stack. Console.Write( "Stack values:" ); PrintValues( myStack, '\t' ); } public static void PrintValues( IEnumerable myCollection, char mySeparator ) { foreach ( Object obj in myCollection ) Console.Write( "{0}{1}", mySeparator, obj ); Console.WriteLine(); } } /* This code produces the following output. Stack values: fox brown quick The (Pop) fox Stack values: brown quick The (Pop) brown Stack values: quick The (Peek) quick Stack values: quick The */
-
∞ foo bar
<?php interface market { public function register( ); private function checkRegister( ); private function sendEmail( ); } /** * Class for marketPlace, the basics, crud and send email */ class marketClass implements market { public $nome = 'Guilherme'; public $email = 'guiii@msn.com'; public $pass = '123'; public $nick = 'guiii'; public function __construct(){ } public function register( ){ try { //do somthing return true; } catch ($e){ // if erros exists, do another thing return false; } } public function checkRegister( ){ if ( $this -> register () ): // do something return true; else: return false; endif; } public function sendEmail( ){ if ( $this -> checkRegister ): mail($foo, $bar, $fooBar) ? return true : return false; else: return false; // do something else endif; } } ?>
-
∞ force umount
force umount -f Force the unmount. This option requires kernel 2.1.116 or later. -l Lazy unmount. Detach the filesystem from the hierarchy immediately, but don't clean up references until it is no longer busy. Requires kernel 2.4.11 or later. e.g. umount -lf /mnt -
∞ Sorting a Multi-Dimensional Array with PHP
//http://firsttube.com/read/sorting-a-multi-dimensional-array-with-php/ function subval_sort($a,$subkey) { foreach($a as $k=>$v) { $b[$k] = strtolower($v[$subkey]); } asort($b); foreach($b as $key=>$val) { $c[] = $a[$key]; } return $c; }
-
∞ aaa
package com.calculadora.android; import android.app.Activity; import android.app.AlertDialog; import android.os.Bundle; import andoid.View.View; import android.View.View.onClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Calculator extends Activity{ private EditText input1; private EditText input2; private EditText solution; private TextView operator; private Calculator mContext; input1 = (EditText) findViewById(R.id.input1); input2 = (EditText) findViewById(R.id.input2); solution = (EditText)findViewById(R.id.solution); operator = (EditText)findViewById(R.id.operator); Button plusButton = (Button) findViewById(R.id.plusbutton); Button minusButton = (Button) findViewById(R.id.minusbutton); Button prodButton = (Button) findViewById(R.id.prodbutton); Button divButton = (Button) findViewById(R.id.divbutton); Button equalButton = (Button) findViewById(R.id.equalbutton); prod.Button.setOnCliclListener(new onClickListener(){ public void onClick(View arg0) { operator.settEXT("*"); } }); divButton.setOnClickListener(new onCLickListener(){ public void onClick(View arg0){ operator.setText("/"); } }); show = new AlertDialogBuilder(mContext).setTitle("Error").setMessage("Operator is null").setPositiveButton("OK", null).show(); } }} -
∞ code for embedding flash and validate trough w3c
<object data="http://www.page.com/file.swf" type="application/x-shockwave-flash" width="190" height="150"><param name="parametro_1" value="true"><param name="parametro_2" value="false"> <param name="movie" value="http://www.page.com/file.swf"> </object>
-
∞ Twitter Status RSS
function fail_whale(){ // get Twitter status RSS $rss = curl_process("http://status.twitter.com/rss"); // parse XML $xmlRss = simplexml_load_string($rss); $count = 0; $out .= "<div style='margin:5px;padding:5px;border:double;'><p><strong> <a href='{$xmlRss->channel->link}'>{$xmlRss->channel->title}</a> - {$xmlRss->channel->description}</strong></p>"; foreach ($xmlRss->channel->item as $item ){ if (++$count < 4){ $out .= "<hr><a href='{$item->guid}'>{$item->title}</a> [<em>{$item->pubDate}</em>]<br \>{$item->description}"; } } $out .= "</div>"; return $out; }
-
∞ DSDT shutdown ix
Scope (\) { Name (PICF, 0x00) Method (_PIC, 1, NotSerialized) { Store (Arg0, PICF) } } OperationRegion (PMRS, SystemIO, 0x0430, 0x1) Field (PMRS, ByteAcc, NoLock, Preserve) { , 4, SLPE, 1 } Method (\_PTS, 1, NotSerialized) { Or (Arg0, 0xF0, Local0) Store (Local0, DBG1) OSTP () If (LEqual (Arg0, 0x01)) {} If (LEqual (Arg0, 0x03)) {} If (LEqual (Arg0, 0x05)) { Store (ESMI, Local0) And (Local0, 0xFB, Local0) Store (Local0, ESMI) Store (0x99, SMIP) Store (Zero, SLPE) Sleep(0x10) } If (LEqual (Arg0, 0x04)) { If (LNot (PICF)) { Sleep (0x64) } } } -
∞ qsort
#include <stdio.h> #include <stdlib.h> // Pivot point : void qsortCentral(int[],int,int);// last element void qsortFirst(int[],int,int); // first element void qsortLast(int[],int,int); // last element void qsortRadom(int[],int,int); // random element int main(int argc, char** argv) { int tab[10000]; int i; long double x; for(i = 0; i < 10000; i++) { tab[i] = 10000 - i; } // printf("%d ", tab[i]); if(i%20 == 0) printf("\n"); } // for(i = 0; i < 2500000; i++) { tab[i] = rand() % 3000000; } //printf("%d ", tab[i]); if(i%20 == 0) printf("\n"); } printf("\n\n"); qsortLast(tab,0,9999); for(i = 0; i < 10000; i++) { printf("%d ", tab[i]); if(i%20 == 0) printf("\n"); } return 0; } void qsortCentral(int t[], int low ,int high) { int i,j; int x, temp; i = low; j = high; x = t[(low+high)/2]; while(i < j) { while(t[i] < x) i++; while(t[j] > x) j--; if(i <= j) { temp = t[i]; t[i] = t[j]; t[j] = temp; i++; j--; } } if(low < j) qsortCentral(t,low,j); if(high > i) qsortCentral(t,i,high); } void qsortFirst(int t[], int low ,int high) { int i,j; int x, temp; i = low; j = high; x = t[low]; while(i < j) { while(t[i] < x) i++; while(t[j] > x) j--; if(i <= j) { temp = t[i]; t[i] = t[j]; t[j] = temp; i++; j--; } } if(low < j) qsortFirst(t,low,j); if(high > i) qsortFirst(t,i,high); } void qsortLast(int t[], int low ,int high) { int i,j; int x, temp; i = low; j = high; x = t[high]; while(i < j) { while(t[i] < x) i++; while(t[j] > x) j--; if(i <= j) { temp = t[i]; t[i] = t[j]; t[j] = temp; i++; j--; } } if(low < j) qsortLast(t,low,j); if(high > i) qsortLast(t,i,high); } void qsortRadom(int t[], int low ,int high) { int i,j; int x, temp; i = low; j = high; // x = t[rand() % (high + 1) + low]; x = t[(rand() % (high - low )) + low]; while(i < j) { while(t[i] < x) i++; while(t[j] > x) j--; if(i <= j) { temp = t[i]; t[i] = t[j]; t[j] = temp; i++; j--; } } if(low < j) qsortRadom(t,low,j); if(high > i) qsortRadom(t,i,high); }
-
∞ timeline layout for mobile browser
--- a/common/twitter.php +++ b/common/twitter.php @@ -1134,13 +1134,17 @@ function theme_timeline($feed) { $date_heading = false; foreach ($feed as $status) { $time = strtotime($status->created_at); + $colspan = 2; + if (setting_fetch('browser') == 'mobile') { + $colspan = 1; + } if ($time > 0) { $date = twitter_date('l jS F Y', strtotime($status->created_at)); if ($date_heading !== $date) { $date_heading = $date; $rows[] = array(array( 'data' => "<small><b>$date</b></small>", - 'colspan' => 2 + 'colspan' => $colspan )); } } else { @@ -1164,6 +1168,12 @@ function theme_timeline($feed) { if ($page != 'user' && $avatar) { array_unshift($row, $avatar); } + if (setting_fetch('browser') == 'mobile') { + if ($page != 'user' && $avatar) { + $html = "{$avatar}<br/>{$html}"; + } + $row = array($html); + } if ($page != 'replies' && twitter_is_reply($status)) { $row = array('class' => 'reply', 'data' => $row); }
-
∞ fix textarea too wide when RT or DM in dabr
--- a/common/twitter.php +++ b/common/twitter.php @@ -769,7 +769,7 @@ function theme_directs_form($to) { } else { $html_to .= "To: <input name='to'><br />Message:"; } - $content = "<form action='directs/send' method='post'>$html_to<br><textarea name='message' cols='50' rows='3' id='message'></textarea><br><input type='submit' value='Send'><span + $content = "<form action='directs/send' method='post'>$html_to<br><textarea name='message' cols='10' rows='3' id='message' style='width:100%; max-width: 400px;'></textarea><br><i $content .= js_counter("message"); return $content; } @@ -910,7 +910,7 @@ function theme_retweet($status) { $text = "RT @{$status->user->screen_name}: {$status->text}"; $length = function_exists('mb_strlen') ? mb_strlen($text,'UTF-8') : strlen($text); $from = substr($_SERVER['HTTP_REFERER'], strlen(BASE_URL)); - $content = "<p>Old style editable retweet:</p><form action='update' method='post'><input type='hidden' name='from' value='$from' /><textarea name='status' cols='50' rows='3' id='s + $content = "<p>Old style editable retweet:</p><form action='update' method='post'><input type='hidden' name='from' value='$from' /><textarea name='status' cols='10' rows='3' id='s $content .= js_counter("status"); if($status->user->protected == 0){ $content.="<br />Or Twitter's new style retweet<br /><form action='twitter-retweet/{$status->id}' method='post'><input type='hidden' name='from' value='$from' /><input type='sub
-
∞ zamiana liter na duze badz na male - wywala seg_fault ; x
SYSEXIT = 1 SYSREAD = 3 SYSWRITE = 4 STDOUT = 1 STDIN = 0 EXIT_SUCCESS = 0 .data input: .skip 128 output: .skip 128 len = 128 .text msg: .ascii "hello world\n" msg_len = . - msg .global _start _start: mov $SYSWRITE, %eax mov $STDOUT, %ebx mov $msg, %ecx mov $msg_len, %edx int $0x80 mov $SYSREAD, %eax mov $STDIN, %ebx mov $input, %ecx mov $len, %edx int $0x80 xor %esi, %esi mov %eax, %ecx #w eax znajduje sie dlugosc lancucha (wartosc zwracana przez SYSREAD) dec %ecx # pozbycie sie znaku konca lancucha '\n' loop: cmp %esi, %ecx je end # warunek zakonczenia sie petli mov input(, %esi, 1), %al # wczytanie jednego znaku do rej. al big: cmp %al, 'Z' jg small cmp %al, 'A' jl fail jmp ok small: cmp %al, 'z' jg fail cmp %al, 'a' jl fail jmp ok ok: btc $5, %eax mov %al, output(, %esi, 1) fail: inc %esi jmp loop end: inc %ecx mov '\n', %eax mov %eax, output(,%esi,1) mov $SYSWRITE, %eax mov $STDOUT, %ebx #mov $INPUT, %ecx #mov $len, %edx mov %ecx, %edx #dlugosc wczytanego lancucha mov $output, %ecx int $0x80 mov $SYSEXIT, %eax mov $EXIT_SUCCESS, %ebx int $0x80
-
∞ Format phone numbers in spreadsheet
="("&MID(A2,1,3)&") "&MID(A2,4,3)&"-"&MID(A2,7,4) -
∞ Manipulación JQuery con etiqueta div
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Efectos de jQuery </title> <script src="../jquery/jquery.js" type="text/javascript"></script> </script> <script type="text/javascript"> $(document).click(function (){ //Aqui asignamos el click al elemento <a> $("a").click(function (){ $("div").hide("fast"); $("div").show("fast"); $("div").slideUp("fast"); $("div").slideDown("fast"); $("div").fadeOut("fast"); $("div").fadeIn("fast"); $("div").animate({width:200, height:200}, "fast"); $("div").animate({top:60, left:100}, "fast"); $("div").animate({width:300, height:300}, "fast"); $("div").animate({top:20, left:50}, "fast"); $("div").animate({width:100, height:100}, "fast"); $("div").animate({top:0, left:0}, "fast"); $("div").animate({width:400, height:400}, "fast"); }); }); </script> </head> <body> <div style="width:400px;height:400px;background-color:#FC0;position:relative;"> <a href="#" class="algo">Presioname!</a> </div> </body> </html>
-
∞ reconfigure plesk vhost
/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=<NOME_DOMINIO> -
∞ bash: random password generator
:' @Author: Miklos Janosi (mjanosi@uakron.edu) @Date: 2010-03-12 Bash one liner to generate random strong password ' dd if=/dev/urandom count=100 2> /dev/null | sha1sum -b - | head -c 8; echo ""
-
∞ mysqldump -- dump a table with specified conditions
mysqldump -- dump a table with specified conditions you can use where clause to specified some conditions to dump a table, e.g. : mysqldump --no-create-db=TRUE --no-create-info=TRUE --add-drop-table=FALSE --default-character-set="gbk" --where="id between 1 and 1000" bbs bbs_post>bbs_post.sql
-
∞ pack a directory and all its content into a tarfile (compressed)
tar zcvf nameofnewarchiv.tar path/to/dir/to/backup
-
∞ Entrevista a un “windowsero”
Entrevista a un “windowsero” 1. ¿Qué sistema operativo usa en su ordenador? ¿Cómo que qué sistema? Pues Windows. ¿Acaso hay otro? 2. ¿Sabe que Windows es inseguro? Sí bueno… pero yo soy un experto en informática. 3. ¿Practica algún deporte de alto riesgo? ¿Vale Windows como deporte? 4. ¿Algún hobby? Instalar parches para Windows. 5. ¿Otras aficiones? Formatear el disco duro. 6. ¿En qué emplea el tiempo, cuando usa el ordenador? En instalar parches, principalmente. Me preocupo mucho por estar siempre seguro 7- ¿Cree que le saca partido a su ordenador? Queda poco tiempo, aparte de instalar parches y formatear. 8. ¿Qué programas son los que más usa? Norton antivirus, Mcafee antivirus, Avp antivirus, Panda antivirus, Avg antivirus, Sophos antivirus, F-secure antivirus, Norman antivirus y Pc-cillin antivirus. 9. ¿Confía en su sistema operativo? ¡POR SUPUESTO! Lo tengo bien protegido teniendo en cuenta que instalo varios parches diarios y tengo nueve antivirus 10. ¿Nota lento su sistema? Solo a veces, cuando no queda mas remedio que reiniciar. 11. ¿Y suele reiniciar a menudo? Sí, pero la culpa es de los que programan los cracks, que no se enteran. 12. ¿Cuál es la tecla que más usa? El reset. Esa no vale; tecla de teclado. Ah! bueno, alguna vez uso tres: ctrl, alt y supr. En realidad no sé para qué valen las otras teclas porque Windows está pensado para manejarse con el ratón y con el reset. 13. ¿Qué opina de los cortafuegos? Son muy necesarios porque hay mucho pirómano cabrón metiendo fuego a los bosques. 14. ¿Conoce algún sistema operativo que no sea Windows? Pues claro: también tengo la Playstation. 15. ¿Ha oído hablar de Linux?: Sí. Eso es Open Surfer. 16. ¿Y no le apetece probarlo? Pues sí, algún día, cuando vaya de vacaciones a alguna playa con buen oleaje. 17. ¿Qué es lo que menos le gusta de Windows? Que solo tenga un salvapantallas de color azul y que luego no pueda quitarlo sin reiniciar. 18. ¿Qué es lo que más le gusta de usar Windows? Que todo es gratis. 19. Pero Windows no es gratis. En realidad puedes pagarlo, pero eso es voluntario. Todos los que conozco lo tienen gratis. No te enteras?
-
∞ vim: Remotely write vi buffer to remote host
:Nwrite scp://user@host//home/cmwise/Desktop/xx.java



Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems