Skip to content

Instantly share code, notes, and snippets.

@glinesbdev
glinesbdev / Main.hs
Last active July 2, 2018 20:26
Haskell - Read JSON and parse data
{-# LANGUAGE
OverloadedStrings
, DeriveGeneric
#-}
module Lib where
import Prelude as P
import Data.Aeson
import Data.Text
@glinesbdev
glinesbdev / database.php
Last active October 4, 2017 04:56
PHP database class [IN PROGRESS]
<?php declare(strict_types = 1);
namespace CMS\Data;
include_once(__DIR__ . '/../helpers/array.php');
/**
* Database class that handles all database connections and related actions.
*
* @param $user The connecting user
* @param $pass Password for the $user
@glinesbdev
glinesbdev / adminController.js
Created May 12, 2017 06:23
Basic Node / Express API
var adminRouter = require('../config/routers')().adminRouter;
var Book = require('../data/models/bookModel');
var db = require('../data/db')();
var adminController = function() {
var books = [
{
title: 'War and Peace',
author: 'Lev Nikolayevich Tolstoy',
genre: 'Historical Fiction',
@glinesbdev
glinesbdev / index.html
Created May 3, 2017 22:39
Longest word in string (immutable.js)
<!doctype html>
<html>
<head>
<title>Immutable</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.1/immutable.min.js"></script>
<script>
const lyrics = "Another dream that will never come true Just to compliment your sorrow Another life that I've taken from you A gift to add on to your pain and suffering Another truth you can never believe Has crippled you completely All the cries you're beginning to hear Trapped in your mind, and the sound is deafening Let me enlighten you This is the way I pray Living just isn't hard enough Burn me alive, inside Living my life's not hard enough Take everything away Another nightmare about to come true Will manifest tomorrow Another love that I've taken from you Lost in time, on the edge of suffering Another taste of the evil I breed Will level you completely Bring to life everything that you fear Live in the dark, and the world is threatening Let me enlighten you This is the way i pray Liv
@glinesbdev
glinesbdev / has_from_file.pl
Last active May 1, 2017 04:58
Create hash from file
#!/usr/bin/perl
use strict;
use warnings;
sub read_line {
our %hash;
my @list = split(" ", shift);
foreach my $word (@list) {
$hash{$word}++;
@glinesbdev
glinesbdev / create_hash.pl
Created May 1, 2017 04:30
Sub to create hash
#!/usr/bin/perl
use strict;
use warnings;
sub create_hash {
my %hash;
my @keys = "@{$_[0]}";
my @values = "@{$_[1]}";
foreach my $i (0 .. $#keys) {
@glinesbdev
glinesbdev / lyrics.pl
Created April 29, 2017 22:46
Unique words in lyrics
#!/usr/bin/perl
use strict;
use warnings;
my $lyric_file = $ARGV[0];
my @unique_words = [];
my $total_words = 0;
open(my $lyrics, '<:encoding(UTF-8)', $lyric_file)
or die "Could not open file '$lyric_file' $!";
@glinesbdev
glinesbdev / card.rb
Last active April 24, 2017 20:25 — forked from camkidman/card.rb
card = Card.first # as an example
card.card_set_id = CardSet.find_by(:name => card.set).id
card.save
# => ActiveRecord::RecordInvalid: Validation failed: Card set must exist
@glinesbdev
glinesbdev / Main.elm
Created April 22, 2017 05:52
Text to Html
module Main exposing (..)
import Html exposing (Html, text, img, div)
import Html.Attributes exposing (src)
sampleText : String
sampleText =
"Once during your turn (before you attack), you may turn all basic Energy attached to all of your Pokémon into Fire Energy for the rest of the turn. This power can't be used if Charizard is affected by a Special Condition."
@glinesbdev
glinesbdev / Main.elm
Created April 21, 2017 14:33 — forked from anonymous/Main.elm
Parse string and replace
module Main exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
sampleText : String
sampleText =
"As long as Rayquaza has any Grass Energy cards attached to it, ignore the effect of Rayquaza's Lightning Storm attack."