Skip to content

Instantly share code, notes, and snippets.

View web_toast.js
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';
View admin_view_logs.svelte
<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 Feb 15, 2019
FreeSWITCH de-register monitor
View index.js
#! /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 Feb 26, 2018
testing window.open prevention
View 1.txt
Sample file.
@avimar
avimar / README.md
Last active Jul 1, 2017
Node.js/Javascript Stack
View README.md

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
View gist:16824955e21781c7e2c6594ef743bc6f
`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`),
View keybase.md

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 Jun 18, 2020 — forked from israelidanny/isracard.js
Checks the validity of a given Isracard credit card number
View isracard.js
/*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 Oct 14, 2021
Convert raw PCAP files into a .wav file
View pcap2wav
#!/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 Sep 15, 2016
north-america-area-codes
View getRegion.js
var NorthAmerica=require('./NorthAmerica.json');
var fp = require('lodash/fp');
function getRegionForAreaCode(areaCode){
return fp.findKey(function(o) {
return o.includes(areaCode);
})(NorthAmerica);
}