Skip to content

Instantly share code, notes, and snippets.

View abacaj's full-sized avatar
💭
Writing more code

Anton Bacaj abacaj

💭
Writing more code
View GitHub Profile
/*
this function will take in a due date and determine the remaining days until something is due from the current date.
*/
public function calculateDate($due_date)
{
$future = strtotime($due_date);
$now = time();
$timeleft = $future-$now;
$daysleft = round((($timeleft/24)/60)/60);
@abacaj
abacaj / SassMeister-input-HTML.html
Created April 28, 2015 14:05
Generated by SassMeister.com.
<h1>Hamburger</h1>
<h2>Hamburger</h2>
<h3>Hamburger</h3>
<h4>Hamburger</h4>
<h5>Hamburger</h5>
<h6>Hamburger</h6>
@abacaj
abacaj / SassMeister-input-HTML.html
Created June 4, 2015 21:21
Generated by SassMeister.com.
<div>
<span class="primary">#</span>
<span class="primary-l-1">#</span>
<span class="primary-l-2">#</span>
<span class="primary-l-3">#</span>
<span class="primary-l-4">#</span>
</div>
<div>
<span class="secondary">#</span>
@abacaj
abacaj / fibonacci.js
Created November 16, 2015 15:58
A simple implementation of fibonacci in javascript.
function fibonacci(size) {
var first = 0,
second = 1,
next,
count = 2,
result = [first, second];
if(size < 2) {
console.log(result);
@abacaj
abacaj / dom-util.js
Last active November 16, 2015 16:03
High performance utility for manipulating DOM classes.
var testDiv = document.querySelector('.test-div');
function filterSpaces(strArray) {
return strArray.filter(function(str) {
return /\S/.test(str);
});
}
function addClass(elem, className) {
var classes = filterSpaces(elem.className.split(' '));
// Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
function fizzbuzz() {
for (var i = 1; i <= 100; i++) {
var str = "";
str += (i % 3 === 0) ? "fizz" : "";
str += (i % 5 === 0) ? "buzz" : "";
str = (str) ? str : i;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter base directory:");
var basePath = Console.ReadLine();
Console.WriteLine("Enter destination directory (this will be created for you, make sure it doesn't exist):");
var destination = Console.ReadLine();
var directories = System.IO.Directory.EnumerateDirectories(basePath);
@abacaj
abacaj / HttpHandler.scala
Last active October 5, 2016 16:50
Using a Map to hold routes with Akka
import scala.collection.mutable.Map
import scala.concurrent.ExecutionContextExecutor
import akka.http.scaladsl.model.ContentTypes
import akka.http.scaladsl.model.HttpEntity
import akka.http.scaladsl.model.HttpEntity.ChunkStreamPart
import akka.http.scaladsl.model.HttpEntity.apply
import akka.http.scaladsl.model.HttpProtocols
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.model.StatusCode
@abacaj
abacaj / js-observables-binding.md
Created January 30, 2017 15:58 — forked from austinhyde/js-observables-binding.md
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@abacaj
abacaj / main.dart
Last active September 15, 2018 18:24
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: 'Navigation Basics',
home: FirstScreen(items: List<String>.generate(40, (i) => "Item $i")),
));
}