Skip to content

Instantly share code, notes, and snippets.

@sxwebdev
sxwebdev / num2str.js
Last active November 20, 2017 09:30
Convert сash money from digits to words in Russian second version
const trimMiddle = (text) => {
return text.trim().replace(/\s\s+/g,' ');
}
const trimAll = (text) => {
return text.replace(/\s+/g,'');
}
const roundTo = (n,kop) => {
let x=0;
if (typeof(n)==='number')
if (Number.isInteger(n))
@sxwebdev
sxwebdev / arrayToObject.js
Created June 5, 2017 17:45
array to object es6
const arrayToObject = (array) => {
return array.reduce(function(result, item) {
var key = Object.keys(item)[0];
if(Array.isArray(item[key])) {
item[key] = arrayToObject(item[key]);
}
result[key] = item[key];
return result;
@sxwebdev
sxwebdev / calculate_ds.js
Last active December 6, 2017 17:26
Calculate distance and speed by latitude and longitude. es6 javascript
const calculate_ds = (lat1, lon1, lat2, lon2, timestamp1, timestamp2) => {
lat1 = lat1 * Math.PI / 180.0;
lon1 = lon1 * Math.PI / 180.0;
lat2 = lat2 * Math.PI / 180.0;
lon2 = lon2 * Math.PI / 180.0;
const r = 6378100;
@sxwebdev
sxwebdev / tab-trigger.js
Last active March 30, 2018 03:43 — forked from wesbos/tab-trigger.js
How to properly get a TAB trigger working with Emmet inside of JSX
{
"keys": ["tab"],
"command": "expand_abbreviation_by_tab",
// put comma-separated syntax selectors for which
// you want to expandEmmet abbreviations into "operand" key
// instead of SCOPE_SELECTOR.
// Examples: source.js, text.html - source
"context": [
{
@sxwebdev
sxwebdev / console_log.sublime-snippet
Created March 30, 2018 03:56
console_log.sublime-snippet
<snippet>
<content><![CDATA[console.log($1);$0]]></content>
<tabTrigger>clog</tabTrigger>
<scope>text.html,source.js,source.js.jsx</scope>
<description>console.log()</description>
</snippet>
@sxwebdev
sxwebdev / Sublime.User.Settings.json
Created July 4, 2018 22:50
Sublime Text 3 User Settings
{
"detect_indentation": false,
"fallback_encoding": "Cyrillic (Windows 1251)",
"font_size": 12,
"ignored_packages":
[
"Vintage"
],
"update_check": false,
"show_definitions": false
@sxwebdev
sxwebdev / LICENCE SUBLIME TEXT
Created August 12, 2018 20:53
Sublime Text 3 Serial key build is 3176
## Sublime Text 3 Serial key build is 3176
> * Added these lines into /etc/hosts
127.0.0.1 www.sublimetext.com
127.0.0.1 license.sublimehq.com
> * Used the license key
----- BEGIN LICENSE -----
@sxwebdev
sxwebdev / webpack.config.dev.js
Created August 24, 2018 06:17
add jquery to webpack
plugins: [
new webpack.ProvidePlugin({
$: "jquery/dist/jquery.min.js",
jQuery: "jquery/dist/jquery.min.js",
"window.jQuery": "jquery/dist/jquery.min.js"
})
];
@sxwebdev
sxwebdev / gist:fb82be7b783a34dddcfd186a8b3d335e
Created August 24, 2018 21:28 — forked from sabarasaba/gist:3080590
Remove directory from remote repository after adding them to .gitignore
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@sxwebdev
sxwebdev / medianHeap.java
Created September 30, 2019 13:21
Java algorithm to get the running median for an array of integer.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
/**
* The add number method
*/