Skip to content

Instantly share code, notes, and snippets.

View 0x1ad2's full-sized avatar
👾
01111001 01101111

Dennis Bruijn 0x1ad2

👾
01111001 01101111
View GitHub Profile
@0x1ad2
0x1ad2 / Package.json
Created September 14, 2015 13:22
My package.json that is used in combination with my gulpfile
{
"devDependencies": {
"gulp-autoprefixer": "^3.0.1",
"gulp-concat": "^2.6.0",
"gulp-cssbeautify": "^0.1.3",
"gulp-csslint": "^0.2.0",
"gulp-jsbeautifier": "^1.0.1",
"gulp-jshint": "^1.11.2",
"gulp-less": "^3.0.3",
"gulp-minify-css": "^1.2.1",
@0x1ad2
0x1ad2 / languages.php
Created December 3, 2015 08:38
PHP Dutch languages array
<?php
return [
"abk" => "Abchazisch",
"ada" => "Adangme",
"ady" => "Adygees",
"orm" => "Afaan Oromo",
"aar" => "Afar",
"afh" => "Afrihili",
"afr" => "Afrikaans",
Verifying that +0x1ad2 is my blockchain ID. https://onename.com/0x1ad2
@0x1ad2
0x1ad2 / mutator.php
Last active May 12, 2016 12:13
Dutch date mutator eloquent model
<?php
/**
* Get created at attribute and mutate to Dutch format and Dutch timezone
*/
public function getCreatedAtAttribute($date)
{
return \Carbon::createFromFormat('Y-m-d H:i:s', $date)->copy()->tz('Europe/Amsterdam')->format('d-m-Y H:i:s');
}
@0x1ad2
0x1ad2 / MyHttpPostMethod.ts
Last active March 8, 2017 08:57
HTTP GET example Angular
import {Headers, Http, Response} from "@angular/http";
export class GenericClass {
constructor(public http: Http) {}
public MyHttpPostMethod() {
// create a new promise and resolve it if possible
return new Promise((resolve) => {
@0x1ad2
0x1ad2 / tabs.service.ts
Last active January 15, 2019 00:06
A service to hide and show tabs in Ionic 2
import {Injectable} from '@angular/core';
// Declare TabsService as a provider in app.module.ts
// Inject TabsService in your class: constructor(public tabs: TabsService){}
// Use the this.tabs.hide() or this.tabs.show() methods wherever you want
@Injectable()
export class TabsService {
constructor() {}
public hide() {
#! /usr/bin/env node
// will tell shell enviroment which program it needs execute this, in our case it's node
// always run your code in strict mode
"use strict";
console.log(`My first Node CLI app 🎉`);
// make a list of frequently used binaries
const frequentlyUsedBinaries = [
"iterm2",
"visual-studio-code",
"google-chrome",
"zsh",
"whatsapp",
"spectacle",
"spotify",
"slack",
// require the enquirer module
const { MultiSelect } = require("enquirer");
// create a new multi select prompt
const multiSelectPrompt = new MultiSelect({
name: "value",
message: "Select all the binaries that you want to install",
choices: frequentlyUsedBinaries
});
// require utility tools and child_process exec to execute CLI commands
const util = require("util");
const exec = util.promisify(require("child_process").exec);
// define a async function execute commands
async function executeCommands(CommandLineString) {
const { stdout, stderr } = await exec(CommandLineString);
console.log("Standard output:", stdout);
console.log("Standard error:", stderr);
}