Skip to content

Instantly share code, notes, and snippets.

View AntonisFK's full-sized avatar
💭
Pushin 🅿️

Antonis AntonisFK

💭
Pushin 🅿️
  • Infuse
  • San Francisco
View GitHub Profile
@AntonisFK
AntonisFK / koa-query-string.ts
Created February 28, 2020 17:00
override request get/set query method to allow comma notation in query params
import merge from 'merge-descriptors';
import qs from 'qs';
import Application from 'koa';
// eslint-disable-next-line func-names
module.exports = function(app: Application) {
merge(app.request, {
get query() {
const str = this.querystring;

Useful tips

Move styles from style tag to inline

svgo path/to/file.svg --enable=inlineStyles --config '{ "plugins": [ { "inlineStyles": { "onlyMatchedOnce": false } }] }' --pretty

@AntonisFK
AntonisFK / 01.ts
Created June 28, 2018 17:10 — forked from jhades/01.ts
ng-template, ng-container and ngTemplateOutlet examples
@Component({
selector: 'app-root',
template: `
<ng-template>
<button class="tab-button"
(click)="login()">{{loginText}}</button>
<button class="tab-button"
(click)="signUp()">{{signUpText}}</button>
</ng-template>
## not trasnlated 
<trans-unit id="3a6587da2d3253a25e76d6d9621c9d8ce8e03f59" datatype="html">
<source>
Passwords do not match
</source>
<context-group purpose="location">

app/loop-ui/login/login.component.ts

@AntonisFK
AntonisFK / reduceObjectArr.ts
Created February 13, 2018 17:18
Reduce an array of objects to one object
const resultObject = resArr.reduce((result, currentObject) => {
for (const key in currentObject) {
if (currentObject.hasOwnProperty(key)) {
result[key] = currentObject[key];
}
}
return result;
}, {});
func fib(until n: Int) -> Void {
var num1 = 0
var num2 = 1
for _ in 0...n {
let num = num1 + num2
print(num)
num1 = num2
@AntonisFK
AntonisFK / component.js
Created January 23, 2017 18:07
angular material pagination
'use strict';
angular.module('myApp')
.component('myComponent', {
templateUrl: 'myComponent.html',
controller: function ($scope) {
var vm = this;
@AntonisFK
AntonisFK / autocomplete.html
Created December 21, 2016 18:20
angular material md-autocomplete with google maps autocomplete
<md-autocomplete flex
md-input-name="address autocomplete"
md-floating-label="Address"
md-no-cache="true"
md-selected-item="$ctrl.selectedItem"
md-search-text-change="$ctrl.search($ctrl.searchText)"
md-search-text="$ctrl.searchText"
md-items="item in $ctrl.search($ctrl.searchText)"
md-item-text="item"
md-min-length="1"
@AntonisFK
AntonisFK / copy.js
Created December 7, 2016 21:15
angular directive to copy to clipboard
(function() {
.directive('copyToClipboard', function ($window) {
var body = angular.element($window.document.body);
var textarea = angular.element('<textarea/>');
textarea.css({
position: 'fixed',
opacity: '0'
});
function copy(toCopy, callback) {
@AntonisFK
AntonisFK / match.js
Created November 22, 2016 20:05
directive used for email or password confirmation.
.directive('match', function($parse) {
return {
require: 'ngModel',
link: function(scope, elem, attrs, ctrl) {
scope.$watch(function() {
return $parse(attrs.match)(scope) === ctrl.$modelValue;
}, function(currentValue) {
ctrl.$setValidity('mismatch', currentValue);
});
}