Skip to content

Instantly share code, notes, and snippets.

@avimar
avimar / web_toast.js
Created February 10, 2021 15:49
Web Toasts
import Toastify from 'toastify-js'; //https://github.com/apvarun/toastify-js/blob/master/README.md
import "toastify-js/src/toastify.css";
//To use:
//import toast from '../web_toast.js';
//toast(message,class(optional), options)
//My default is that the toast stays open until dismissed and defaults to bootstrap's "bg-info" if no class is specified.
//NOTE: In an SPA, you'll need to clear any persistent toasts on page switch
//use import {closeAll as clearToasts} from './web_toast.js';
<script>
export let params={};
export let service=null;
export let id=null;
import Fa from 'svelte-fa'
import { faEdit, faPlus, faTrash } from '@fortawesome/free-solid-svg-icons';
import feathers from '../web_feathers.js';
const rest = feathers.service('logs');
@avimar
avimar / index.js
Created February 15, 2019 08:03
FreeSWITCH de-register monitor
#! /usr/bin/node
var nodemailer = require("nodemailer");
var transport = nodemailer.createTransport("sendmail");
function fix_len(num, len){
if(len<=5) return ("00000" + num).slice(-len);
else {
var seed="0000000000";
while(seed.length<len) seed+=seed;
@avimar
avimar / 1.txt
Last active February 26, 2018 16:07
testing window.open prevention
Sample file.
@avimar
avimar / README.md
Last active July 1, 2017 14:13
Node.js/Javascript Stack

Programming Environment:

node.js backend:

  • nconf: loadable, pluggable configuration
  • restify: instead of express, it's oriented for APIs
  • bunyan: for logging, built in support from restify
  • knex.js: SQL query builder/promises/pooling (but it's not an ORM)
  • PM2: deploy and clustering
@avimar
avimar / gist:16824955e21781c7e2c6594ef743bc6f
Created February 17, 2017 06:09
innodb not optimizing?
`show create table logs_fs`
CREATE TABLE `logs_fs` (
`uuid` char(36) DEFAULT NULL,
`host` varchar(4) DEFAULT NULL,
`date` datetime(6) NOT NULL,
`hrtime` bigint(20) unsigned NOT NULL,
`level` tinyint(4) DEFAULT NULL,
`value` text,
KEY `uuid` (`uuid`),

Keybase proof

I hereby claim:

  • I am avimar on github.
  • I am avimarcus (https://keybase.io/avimarcus) on keybase.
  • I have a public key whose fingerprint is 1AFA CC40 32FD 2FE9 BCE3 88FE D5DD 1501 34E0 ABD8

To claim this, I am signing this object:

@avimar
avimar / isracard.js
Last active June 18, 2020 10:04 — forked from etodanik/isracard.js
Checks the validity of a given Isracard credit card number
/*License: MIT*/
function isracardCheck(num) {//algorithm explanation: https://web.archive.org/web/20140227235803/http://povolotski.me/2013/09/24/isracard-credit-card-number-validation-2/
if(typeof num !== 'number') num=''+num;
if(num.length < 8 || num.length > 9) return false;
var sum=0;
num.split('').forEach(function(val,key){
sum+=parseInt(val,10)*(num.length-key);
})
return sum % 11 == 0;
}
@avimar
avimar / pcap2wav
Last active March 1, 2023 22:32
Convert raw PCAP files into a .wav file
#!/bin/bash
#
# pcap2wav
# Original Author: Michael Collins <msc@freeswitch.org>
#Standard disclaimer: batteries not included, your mileage may vary...
# Updated by Avi Marcus <avi@bestfone.com>
#
# Accepts arg of pcap file w/only 2 RTP streams
# Creates a .<codec> file and a .wav file
# For codecs other than PCMA and PCMU the script calls fs_cli and does a little recording to create the wav file(s)
@avimar
avimar / getRegion.js
Last active September 15, 2016 04:20
north-america-area-codes
var NorthAmerica=require('./NorthAmerica.json');
var fp = require('lodash/fp');
function getRegionForAreaCode(areaCode){
return fp.findKey(function(o) {
return o.includes(areaCode);
})(NorthAmerica);
}