Skip to content

Instantly share code, notes, and snippets.

Anton Bacaj abacaj

View GitHub Profile
View main.dart
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")),
));
}
@abacaj
abacaj / js-observables-binding.md
Created Jan 30, 2017 — forked from austinhyde/js-observables-binding.md
Vanilla JavaScript Data Binding
View js-observables-binding.md

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);
View move_files.cs
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);
View fizzbuzz.js
// 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;
@abacaj
abacaj / HttpHandler.scala
Last active Oct 5, 2016
Using a Map to hold routes with Akka
View HttpHandler.scala
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 / fibonacci.js
Created Nov 16, 2015
A simple implementation of fibonacci in javascript.
View fibonacci.js
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 Nov 16, 2015
High performance utility for manipulating DOM classes.
View dom-util.js
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(' '));
@abacaj
abacaj / SassMeister-input-HTML.html
Created Jun 4, 2015
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<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 / SassMeister-input-HTML.html
Created Apr 28, 2015
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<h1>Hamburger</h1>
<h2>Hamburger</h2>
<h3>Hamburger</h3>
<h4>Hamburger</h4>
<h5>Hamburger</h5>
<h6>Hamburger</h6>
View calculateDate_php
/*
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);
You can’t perform that action at this time.