Skip to content

Instantly share code, notes, and snippets.

View gideondsouza's full-sized avatar

Gideon Israel Dsouza gideondsouza

  • Dransfeld, Germany
View GitHub Profile
@gideondsouza
gideondsouza / ProjectEulerProblem3.pl
Created January 26, 2013 14:32
Created by www.tryperl.com. Updated on 26-0-113 at 20 hour(s)
#!/usr/bin/perl
# Solution to projecteuler.net/problem=3
# Question:
# The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143 ?
# Answer: 6857
use strict;
use warnings;
@gideondsouza
gideondsouza / newfile
Created January 26, 2013 12:26
the description for this gist
Awesome contents
@gideondsouza
gideondsouza / hello_tryperl.pl
Last active December 11, 2015 18:28
A welcome script that is loaded on www.tryperl.com
use strict;
use warnings;
############################################
#__ __ _____ _ _ _____ _ _ _____
#\ \ / /\ | __ \| \ | |_ _| \ | |/ ____|
# \ \ /\ / / \ | |__) | \| | | | | \| | | __
# \ \/ \/ / /\ \ | _ /| . ` | | | | . ` | | |_ |
# \ /\ / ____ \| | \ \| |\ |_| |_| |\ | |__| |
# \/ \/_/ \_\_| \_\_| \_|_____|_| \_|\_____|
@gideondsouza
gideondsouza / stackoverflow_api_test.pl
Created January 15, 2013 18:59
stackoverflow_api_test
print "SE";
@gideondsouza
gideondsouza / func_test.pl
Created January 14, 2013 02:49
func tests for perl
use strict;
print "Hello";
<!doctype html>
<html>
<head>
<title>Dancr</title>
<link rel=stylesheet type=text/css href="<% css_url %>">
</head>
<body>
<div class=page>
<h1>Dancr</h1>
<div class=metanav>
#this is a utility method that will convert a query string into a hash
sub parse_query_str {
my $str = shift;
my %in = ();
if (length ($str) > 0){
my $buffer = $str;
my @pairs = split(/&/, $buffer);
foreach my $pair (@pairs){
my ($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
get '/auth/github/callback' => sub {
#github sends us a code to authenticate. Here we need to retrieve it
my $code = params->{'code'};
#create a new instance of LWP:UserAgent
my $browser = LWP::UserAgent->new;
#send a post request for an access token
my $resp = $browser->post('https://github.com/login/oauth/access_token',
[
#these two are global variables in our dancer app
client_id => $client_id,
#on the top
my $client_id = "YOUR CLIENT ID HERE";
my $client_secret = "YOUR SECRET ID HERE";
#route to login
get '/login' => sub {
#redirect the user to githubs login/authorize page
#we pass in a silly state (x12) ideally this should be generated
redirect "https://github.com/login/oauth/authorize?&client_id=$client_id&state=x12";
};
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>::Uploadify Example::</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.uploadify-3.1.min.js")"></script>