<?=rtrim(ltrim(str_replace(", 1", ", ",chunk_split(implode(range(10000, 19999)), 5,", ")), '1'), ', ');?>
Tag Archive for generator
PIN Generator 1 line
The Absolute Shortest 4 Digit PIN
<? for($i=0; $i < 10000; $i++) echo ($i != 9999 ? substr(('0000'.$i), -4).', ' : substr(('0000'.$i), -4).''); ?>
Youtube Download Link Generator
//YouTube Video Download Link Generator -- jacksont123 (2008)
function str_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); }
function get_youtube_download_link(){
$youtube_link = $_GET['youtube'];
$youtube_page = file_get_contents($youtube_link);
$v_id = str_between($youtube_page, "&video_id=", "&");
$t_id = str_between($youtube_page, "&t=", "&");
$flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id";
$hq_flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=6";
$mp4_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=18";
$threegp_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=17";
echo " Download (right-click > save as):
";
echo "<a href="$flv_link">FLV</a>
";
echo "<a href="$hq_flv_link">HQ FLV (if available)</a>
";
echo "<a href="$mp4_link">MP4</a>
";
echo "<a href="$threegp_link">3GP</a><br><br>
";
}
Random Key Generator
function createRandomKey($amount){
$keyset = "abcdefghijklmABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$randkey = "";
for ($i=0; $i<$amount; $i++)
$randkey .= substr($keyset, rand(0, strlen($keyset)-1), 1);
return $randkey;
}
Random pronounceable passwords generator
function auth_pwgen(){
$pw = '';
$c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones
$v = 'aeiou'; //vowels
$a = $c.$v; //both
//use two syllables...
for($i=0;$i < 2; $i++){
$pw .= $c[rand(0, strlen($c)-1)];
$pw .= $v[rand(0, strlen($v)-1)];
$pw .= $a[rand(0, strlen($a)-1)];
}
//... and add a nice number
$pw .= rand(10,99);
return $pw;
}
Generate XHTML on the command line with XML::API::XHTML
perl -e "use XML::API::XHTML; my $d = new XML::API::XHTML(); $d->head_open(); $d->title('hello world!'); $d->script({type => 'text/javascript'}, '/* hello scripts! */'); $d->head_close(); $d->body_open(); $d->h1({style => 'color:red'}, 'Hi nerd!'); print $d;" | tidy -q -o temp.html
Category: Uncategorized |
Tags: automation, code, commandline, cpan, cygwin, engine, generator, howto, html, markup, module, one-liners, oo, perl, template, tidy, w3, xhtml
Wrap tab-delimited strings in HTML
#! /usr/bin/perl -w
use strict;
#Time-stamp: <2005-01-12 11:30:05 NSussman>
############################################################
# #
# #
# #
# NOAH SUSSMAN #
# #
# Tabs To Targets #
# #
# Created Jan 12 2005 at 1:10am #
# #
# Given tab-delimited data, place each line into a #
# heredoc and print to STDOUT then go on to the #
# next line #
# #
# Ignore #commented lines and blank lines. #
# #
# #
############################################################
my $input_file= shift; #file containing tab-delimited data
open(TABBED_DATA_HANDLE, $input_file) || die("Couldn't open $input_file
");
chomp(my @whole_file=<TABBED_DATA_HANDLE>);
foreach my $one_line (@whole_file) {
next if ($one_line =~ m/^s*$/); #ignore blank lines
next if ($one_line =~ m/^#/); #ignore lines starting with "#"
my @record = split(/ /, $one_line);
print "
";
#Place targets in the heredoc.
print <<CODEFRAGMENT;
<!--////////////////$record[2] block of html////////////////////////////////////////////////////////////////-->
<tr>
<td class="smelly">$record[1]</td>
<td class="dogfood">$record[0]</td>
<td class="teaParty">$record[2]</td>
</tr>
<!--////////////////end of $record[2] block of html////////////////////////////////////////////////////////////////-->
CODEFRAGMENT
#end of heredoc.
print "
";
}
=item
Here is an example data file:
big fuzzy bear
little orange kangaroo
large grumpy koala
small sleepy panda
=cut
Category: Uncategorized |
Tags: 2005, code, data, generator, heredoc, html, publish, tab-delimited, utilities
Java prime number generator
package com.destiney.Prime;
class Prime
{
public static void main( String args[] )
{
int x, y, c = 0;
for( x = 2; x < 1000; x++ )
{
if( x % 2 != 0 || x == 2 )
{
for( y = 2; y <= x / 2; y++ )
{
if( x % y == 0 )
{
break;
}
}
if( y > x / 2 )
{
System.out.println( x );
c++;
}
}
}
System.out.println( "
Total: " + c );
}
}
C++ random number generator
#include <iostream>
#include <cstdlib>
#include <ctime>
int main(int argc, char *argv[]){
if(argc != 3){
cout << "Usage: " << endl;
cout << " rand [int x] [int y]" << endl;
cout << " [x] = highest possible value of a random number" << endl;
cout << " [y] = quantity of random numbers created" << endl << endl;
exit(1);
}
long int M = atoi(argv[1]);
int quantity = atoi(argv[2]);
srand(time(NULL));
for(int count = 1; count <= quantity; ++count)
cout << (((int)(((double)rand()/(double)(RAND_MAX+1))*M))*-1)+1 << endl;
return 0;
}