Skip to content

Instantly share code, notes, and snippets.

@Lodo4ka
Lodo4ka / settings.json for linux vs code
Created July 24, 2019 08:26
config vs code for linux development javascript
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnSave": false,
// "css.fileExtensions": [
// "css",
// "scss",
// "less"
// ],
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnSave": false,
// "css.fileExtensions": [
// "css",
// "scss",
// "less"
// ],
@Lodo4ka
Lodo4ka / customValidation.js
Created July 17, 2019 09:36
custom directive angularjs for replace input with only numbers
(function() {
angular.module("BauVoiceApp").directive("customValidation", function() {
return {
require: "ngModel",
link: function(scope, element, attrs, modelCtrl) {
modelCtrl.$parsers.push(function(inputValue) {
const numberPattern = /\d+/g;
let transformedInput = inputValue.match(numberPattern)[0];
if (transformedInput != inputValue) {
modelCtrl.$setViewValue(transformedInput);
@Lodo4ka
Lodo4ka / get list directive on element angualarjs
Created July 10, 2019 08:06
angularjs injector describe directive on element
let a = angular.element($0).injector();
a.get("formDirective");
function maybe(fn)
return function _maybe(...args) {
// Note that the == is deliberate.
if ((args.length === 0) || args.some(a => (a == null)) {
return undefined;
}
return fn.apply(this, args);
}
}
@Lodo4ka
Lodo4ka / gist:78e8bd9b606e56c83c5f6b2bea2791aa
Created July 6, 2019 13:14
sort table by javascritp with number and characters
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<style>
th {
cursor: pointer;
}
const removeProperties = (object, ...keys) =>
Object.entries(object).reduce(
(prev, [key, value]) => ({
...prev,
...(!keys.includes(key) && { [key]: value }),
}),
{}
);
angular.element(document).injector().get(‘service.name’);
const clearFieldOfObject = obj => {
Object.keys(obj).map(key => {
if (
key !== "status_in_work" &&
key !== "status_paid" &&
key !== "status_wait_mount" &&
key !== "status_delivered" &&
key !== "status_mounted" &&
key !== "status_fullfilled"
) {