Skip to content

Instantly share code, notes, and snippets.

View cardil's full-sized avatar

Chris Suszynski cardil

View GitHub Profile
@cardil
cardil / gist:2355211
Created April 10, 2012 22:43
CrontabManager simple example
<?php
use php\manager\crontab\CrontabManager;
$crontab = new CrontabManager();
$job = $crontab->newJob();
$job->on('* * * * *');
$job->onMinute('20-30')->doJob("echo foo;");
$crontab->add($job);
$job->onMinute('35-40')->doJob("echo bar;");
$crontab->add($job);
window.wave = window.wave || {};
//noinspection ThisExpressionReferencesGlobalObjectJS
wave.env = this;
/* COMPRESSOR START CUT */
wave.Loader = (function (window) {
"use strict";
var out, instance;
out = function(window) {
@cardil
cardil / CompositionJava7LombokExample.java
Created October 15, 2015 10:12
Example of composition usage in Java 7 & 8 insead of JavaScript. Follow up to: https://www.youtube.com/watch?v=wfMtDGfHWpA
import lombok.Delegate;
interface Barker {
void bark();
class DefaultImpl implements Barker {
@Override
public void bark() {
System.out.println("Bark, Bark!");
}
@cardil
cardil / SliderInput.java
Last active December 12, 2015 05:38
Vaadin slider with text box for input value, with events and implementing Field so suitable for forms. See: http://img844.imageshack.us/img844/5530/zrzutekranuz20130206145.png
/*
* Copyright (c) 2013 Wave Software.
*
* The source code contained in this file is owned and/or is subject to
* copyright by Wave Software. Only employees of the company, or other
* cooperating entities responsible for developing, maintaining and implementing
* this code shall be entitled to inspect the contents of the file. If you are
* not one of them, delete the file and let us know about a possible theft
* attempt by e-mail to: info@wavesoftware.pl. This file may not be reproduced,
* used in whole or in part, by persons not listed above. If you need
@cardil
cardil / eid-in-ang.js
Created January 15, 2016 13:06
Example how to use Eid in Angular 1.x apps (featuring also business filters!)
(function() {
'use strict';
var EidPreconditions = Eid.preconditions;
var checkNotNullable = EidPreconditions.checkNotNullable;
var checkArgument = EidPreconditions.checkArgument;
var tryToExecute = EidPreconditions.tryToExecute;
var app = angular.module('eid-in-ang', []);
var eidifyServiceCall = function(eid, target, operation) {
checkNotNullable(operation, "20160115:124506", 'Operation should not be nullable');
@cardil
cardil / MainControllerSpec.groovy
Last active February 13, 2016 22:20
An example of proposed JavaSpec as a direct port of RSpec
import pl.wavesoftware.exampleapp.MainController
import static pl.wavesoftware.jspec.DSL.*
describe(MainController, {
let 'instance', { describedClass.newInstance }
sharedExamples('not throwing any errors', {
it { expect { subject }.notTo raiseError }
it { expect(subject).notTo beNull }
})
@cardil
cardil / DozerProxyMapping.java
Last active March 31, 2016 08:56
DozerProxyMapping prototype idea
ProxyConfigurator configurator = new ProxyConfigurator();
Mapping mapping = configurator.newMappingBuilder()
.from(User.class, (user) -> user.getRole().getName() )
.to(UserQuery.class, (query) -> query.getRoleName() )
.andReverseAlso()
.build();
configurator.addMapping(mapping);
configurator.addMapping(
configurator.newMappingBuilder()
@cardil
cardil / change-ts-to-human-readable.groovy
Created June 30, 2016 12:19
Changing Date from timestame to human readable Date from String
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
directory = args[0] // directory
d = Paths.get(directory)
stream = Files.newDirectoryStream(d)
stream.each {
p = it as Path;
println "file -> ${p}"
@cardil
cardil / Vagrantfile
Created September 19, 2017 13:36
Example Vagrantfile to test puppet agent-server connections
Vagrant.configure("2") do |config|
config.vm.box = 'boxcutter/centos7'
config.vm.define :master do |m|
m.vm.network "private_network", ip: "192.168.50.4"
m.vm.provider "virtualbox" do |v|
v.memory = 768
v.cpus = 2
end
end
@cardil
cardil / modules.rb
Created February 21, 2018 21:36
Example custom fact for Facter 3+ with 2 implementations
Facter.add(:modules) do
setcode { simple }
def simple
codedir = Facter::Core::Execution.exec('puppet config print codedir')
list = Facter::Core::Execution.exec("ls #{codedir}/modules").split("\n")
{
count: list.size,
list: list.freeze