Skip to content

Instantly share code, notes, and snippets.

View tudorconstantin's full-sized avatar
🏠
Working from home

Tudor Constantin tudorconstantin

🏠
Working from home
View GitHub Profile
@tudorconstantin
tudorconstantin / mojo_steps.pl
Created March 29, 2012 08:57
Step definitions for Mojolicious Boilerplate
Given qr/a mojo test object for the "(.+)" application/, func ($c) {
use_ok( $1 );
my $tm = Test::Mojo->new( $1 );
ok( $tm, "Object created" );
$c->stash->{'feature'}->{'tm'} = $tm;
ok( $c->stash->{'feature'}->{'tm'}, "Got our Test::Mojo object" );
};
When qr/I go to "(.+)"/, func ($c) {
my $route_url = '';
@tudorconstantin
tudorconstantin / gist:2343752
Created April 9, 2012 14:19
sample to add "featured in Perl Weekly" ribbon to a blogger blog
<a href="http://perlweekly.com" style=display:scroll;position:fixed;top:0px;right:0px;z-index:10; ><img src="https://github.com/tudorconstantin/Perl-Weekly-Ribbons/raw/master/ribbon%20transparent.png" alt="Featured in Perl Weekly" /></a>
@tudorconstantin
tudorconstantin / generic_resource_update.pl
Created August 15, 2012 11:35
generic REST update with Mojolicious and DBIx::Class
sub update{
my $self = shift;
my $result_rs = $self->app->model
->resultset( $self->{resource} )
->search_rs(
{ id => $self->param('id') },
);
return $self->render_not_found if ( scalar( ( $result_rs->all ) ) == 0 );
@tudorconstantin
tudorconstantin / gist:11207833
Created April 23, 2014 08:58
Perl ~ Facebook authentication with Mojolicious in less than 100 LOC
#!/usr/bin/env perl
use Mojolicious::Lite;
use Net::Facebook::Oauth2;
my $config = {
facebook => {
#get the app id and app secret from the settings page of your facebook application
#you create your own fb app from https://developers.facebook.com/ (accessing Apps -> Create a new app)
app_id => '',
@tudorconstantin
tudorconstantin / pyramid.c
Created February 2, 2015 17:46
cs50 mario pyramid
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int y;
int x;
int space;
int hash;
do {
printf("alege un nr intre 0 si 23n");
@tudorconstantin
tudorconstantin / gist:872dd6ef26c72ec64745
Created February 24, 2015 10:59
ratinguri de filme
#include <stdio.h>
#include <string.h>
int main(void)
{
int nrFilme, count, rating, bestRating, lowRating;
char nume[40], filmBun[40], filmSlab[40];
//le initializam inafara range-ului permis intre 0 si 10
bestRating = -1;
@tudorconstantin
tudorconstantin / index.c
Created March 4, 2015 15:54
Find string in string (equivalent of Perl's index core function)
include <stdio.h>
int main(void)
{
char name[3] = "Bob";
char name1[10];
int i = 0;
int found_at_position = -1;
@tudorconstantin
tudorconstantin / index.c
Created March 9, 2015 16:33
c string comparison for dragos
#include <stdio.h>
int main(void)
{
int ctr;
int i = 0;
int found = 0;
char name[3] = "Bob";
char name1[3];
@tudorconstantin
tudorconstantin / book_info_in_struct.c
Created March 21, 2015 19:15
Simple struct to hold book info. Read 3 books and print them
/*This heade file defines a structure for information
about a book*/
#include <stdio.h>
struct bookInfo{
char title[40];
char author[25];
float price;
int pages;
@tudorconstantin
tudorconstantin / calculator.c
Created April 4, 2015 09:51
a cleaner solution to the problem of creating a calculator from CS50
/* Write a program that acts as a simple calculator.The program shuld
alow the user to input data in form number operator number.
The following operators shuld pe recognized: +, -, *, /, S, E, .
The S operator tells the program to set the acumulator to the typed in
number. The E operator tells the program that execution is to end.
The artmethic operatioons are performed on the contenst of the acumulator with the number
that was keyed in accting as a smaple operand
program output
10S set Acumulator to 10