Skip to content

Instantly share code, notes, and snippets.

View adamrecsko's full-sized avatar
🎯
Focusing

Adam Recsko adamrecsko

🎯
Focusing
  • Hungary, Budapest
View GitHub Profile
@adamrecsko
adamrecsko / knockout-numeral
Last active August 22, 2018 05:51
Knockout binding use Numeral.js to format money. It is a requirejs module, the paths of the numeral and the knockout must be defined in the requirejs config.
define(['knockout','numeral'],function(ko,numeral){
ko.bindingHandlers.money = {
update: function (element, valueAccessor,allBindingsAccessor) {
var format = allBindingsAccessor().format || "00,000";
var value = ko.utils.unwrapObservable(valueAccessor());
$(element).text(numeral(value).format(format));
}
};
});
@adamrecsko
adamrecsko / knockout-cuttext
Created March 27, 2014 11:45
Knockout binding for cut text to the required length. It is a require js module. If it less then specified length then cut it and concatenate the trailing to the end of string.
define(['knockout'],function(ko){
ko.bindingHandlers.cuttext = {
update: function (element, valueAccessor,allBindingsAccessor) {
var length = allBindingsAccessor().length || 4294967295; //SAFE MAX_INT
var trailing = allBindingsAccessor().trailing || "";
var value = ko.utils.unwrapObservable(valueAccessor());
if (length<value.length){
value = value.substr(0,length)+trailing;
}
$(element).text(value);
@adamrecsko
adamrecsko / scrollarea
Last active August 29, 2015 14:03
Scrollarea without scrollbars and prevent window scrolling like facebook do.
/*
Style for the scrollarea:
.scrollarea{
height:500px;
overflow: hidden;
}
*/
//scroll speed
var speed = 100;
@adamrecsko
adamrecsko / highlight.pipe.ts
Created May 1, 2016 20:28
Angular2 text highlight pipe
import {PipeTransform, Pipe} from 'angular2/core';
@Pipe({ name: 'highlight' })
export class HighLightPipe implements PipeTransform {
transform(text: string, [search]): string {
return search ? text.replace(new RegExp(search, 'i'), `<span class="highlight">${search}</span>`) : text;
}
}
/** Usage:
@adamrecsko
adamrecsko / wf.ts
Created November 20, 2017 17:55
wfts
interface WorkflowFn {
<A, B, C, D, E, R> (wf: (param1: A, param2: B, param3: C, param4: D, param5: E) => R, param1: A, param2: B, param3: C, param4: D, param5: E): Promise<WorkflowResult<R>>;
<A, B, C, D, R> (wf: (param1: A, param2: B, param3: C, param4: D) => R, param1: A, param2: B, param3: C, param4: D): Promise<WorkflowResult<R>>;
<A, B, C, R> (wf: (param1: A, param2: B, param3: C) => R, param1: A, param2: B, param3: C): Promise<WorkflowResult<R>>;
<A, B, R> (wf: (param1: A, param2: B) => R, param1: A, param2: B): Promise<WorkflowResult<R>>;
@adamrecsko
adamrecsko / jasmine.index.d.ts
Created July 31, 2018 15:42
jasmine index d ts
// Type definitions for jasminewd2 2.0
// Project: https://github.com/angular/jasminewd
// Definitions by: Sammy Jelin <https://github.com/sjelin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="jasmine" />
declare function it(expectation: string, assertion?: () => Promise<void>, timeout?: number): void;
declare function fit(expectation: string, assertion?: () => Promise<void>, timeout?: number): void;
@adamrecsko
adamrecsko / test-example.ts
Created August 7, 2018 06:13
test structure
describe('Test Suite name', () => {
// page objects and services
let login: Login;
beforeEach(async () => {});
afterEach(async () => {});
it('should ....', async () => {
});
it('should ...', async () => {
expect(...);
@adamrecsko
adamrecsko / async_test_decorator.py
Last active November 14, 2018 11:45
Run standard python3 async unittests in the main event loop
from functools import wraps
def async_test():
"""
class ExampleTest(unittest.TestCase):
@async_test()
async test_something():
pass
"""
def decorator(f):
@wraps(f)
@adamrecsko
adamrecsko / LG infrared codes
Created August 31, 2019 14:42 — forked from francis2110/LG infrared codes
Lg infrared codes for making your own remote
on-off->20DF10EF
energy->20DFA956
av. mode->20DF0CF3
input->20DFD02F
tv/rad->20DF0FF0
1->20DF8877
2->20DF48B7
3->20DFC837
4->20DF28D7
5->20DFA857
.blob-num,
.blob-code-inner {
font-size: 17px;
font-family: "CamingoCode";
-webkit-font-smoothing: subpixel-antialiased;
line-height: 25px;
}
.blob-num,
.blob-code-inner,