Skip to content

Instantly share code, notes, and snippets.

@harshals
harshals / simple rest api
Created January 6, 2011 07:23
rest based api on dancer
use lib "lib";
package Library;
use Dancer ':syntax';
use Schema;
use Data::Dumper;
our $VERSION = '0.1';
set serializer => 'JSON';
<script>
function onLoadMe(data){
alert(data);
}
$().ready(function(){
var url = 'http://192.168.2.4:5000/api/Book?callback=onLoadMe';
@harshals
harshals / App1.pm
Created January 28, 2011 12:39
Hosting Multiple Dancer Apps using Plack
package App1;
use strict;
use warnings;
use Dancer ':syntax';
set 'apphandler' => "PSGI";
get '/' => sub {
return "Hello from App1";
function onLoadCategory(books) {
var category_id;
var extra_class = '';
// populate the books on sidebar
$.each(books, function( n,book1) {
category_id =(book1['category_id']);
<script>
</script>
@harshals
harshals / gist:5c7645cc525299817b4c
Created January 8, 2016 10:58 — forked from jerowe/gist:f71fae928cef9a8b6c2c
Catalyst with Perlbrew Setup

Overview

Perlbrew is a way of managing perl versions and application specific libraries.

In general it doesn't require root, unless you want it installed in a location only writable by root. ;)

Its actually not such a great idea to have this in a home directory if you want it shared by multiple users, such as nginx/apache, so it may be a better idea to have your $PERLBREW_ROOT as /opt/perlbrew or something similar

CPAN documentation

@harshals
harshals / instamojo.pl
Last active February 2, 2016 11:46
instamojo api using perl
use JSON::MaybeXS qw/decode_json encode_json/;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
my $params = {
purpose => 'some purpose',
amount => 100
};
my $tx = $ua->build_tx(POST => "https://www.instamojo.com/api/1.1/payment-requests/", form => $params );
$tx->req->headers->header('X-Api-Key' => "your key");
@harshals
harshals / einvoice sample code.pl
Last active August 18, 2022 13:15
sample code to authenticate on einvoice sandbox
#!/usr/bin/perl
#clone of https://einv-apisandbox.nic.in/sample-code-in-java.html
# you need to save the public key of einv-apisandbox.nic.in in same folder
use Crypt::OpenSSL::Random qw/random_bytes/;
use Crypt::OpenSSL::RSA;
use Crypt::Mode::ECB;
use Crypt::PK::RSA;
use Mojo::File;
use Mojo::JSON qw/encode_json decode_json/;
@harshals
harshals / hello-world-options.vue
Last active May 23, 2023 13:15
simple vue3 options and composition component
const App2 = {
data() {
return {
message: "Hello from App 2!",
};
},
methods: {
modifyMessage() {
return "Modified Message"
},