Skip to content

Instantly share code, notes, and snippets.

View ajsb85's full-sized avatar
🖼️
Engaging cognitive processors...

Alexander Salas Bastidas ajsb85

🖼️
Engaging cognitive processors...
View GitHub Profile
@stefanmaric
stefanmaric / deep-diff-angular.js
Last active September 2, 2016 03:22
Deep (recursive) diff function implementation in Angular, lodash and ES6 / ES2015.
function deepDiffRight (left, right) {
// if they are equals, return undefined
if (angular.equals(left, right)) return
// form now on, we can assure that `left` and `right` are not equals (equivalents)
// if `left` and `right` are primitives, value changed
// if `left` is a primitive and `right` an object, value has been replaced with an object
// if `left` is an object and `right` a primitive, value has been replaced with a primitive
// use `_.copy` to prevent object referrence issues
if (!angular.isObject(left) || !angular.isObject(right)) return angular.copy(right)
@dynamis
dynamis / launchapp.jp
Created August 18, 2015 09:06
Firefox OS で特定のアプリを起動する
// launch FM App
navigator.mozApps.mgmt.getAll().onsuccess = function() {
const appId = "app://fm.gaiamobile.org/manifest.webapp";
var urls = [];
var apps = [];
var targetApp = null;
this.result.forEach(function(app) {
urls.push(app.manifestURL);
apps.push(app);
if (app.manifestURL==appId) {
@vedant1811
vedant1811 / lua_functions.c
Created July 25, 2015 14:25
lua_functions accepted by telegram-cli
struct lua_function functions[] = {
{"get_contact_list", lq_contact_list, { lfp_none }},
{"get_dialog_list", lq_dialog_list, { lfp_none }},
{"rename_chat", lq_rename_chat, { lfp_chat, lfp_string, lfp_none }},
{"send_msg", lq_msg, { lfp_peer, lfp_string, lfp_none }},
{"send_typing", lq_send_typing, { lfp_peer, lfp_none }},
{"send_typing_abort", lq_send_typing_abort, { lfp_peer, lfp_none }},
{"send_photo", lq_send_photo, { lfp_peer, lfp_string, lfp_none }},
{"send_video", lq_send_video, { lfp_peer, lfp_string, lfp_none }},
{"send_audio", lq_send_audio, { lfp_peer, lfp_string, lfp_none }},
@Noitidart
Noitidart / _ff-addon-tutorial-jniAndroidToast.js
Last active November 19, 2020 13:55
_ff-addon-tutorial-jniAndroidToast - Using js-ctypes to use JNI to call functions from the Android API, this specific example does the same as the NativeWindow component, it creates a toast message as seen here: https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/NativeWindow/toast
var my_jenv = null;
try {
my_jenv = JNI.GetForThread();
// We declare the classes, methods, etc we will be using: this part is not seen in the native example
var SIG = {
CharSequence: 'Ljava/lang/CharSequence;',
Context: 'Landroid/content/Context;',
GeckoAppShell: 'Lorg.mozilla.gecko.GeckoAppShell;',
Toast: 'Landroid/widget/Toast;', // can use .'s or /'s so `android.widget.Toast` and `android/widget/Toast` both work // from docs page header http://developer.android.com/reference/android/widget/Toast.html#makeText%28android.content.Context,%20int,%20int%29
@matriphe
matriphe / ssh-telegram.sh
Last active April 16, 2025 20:24
Bash Script to notify via Telegram Bot API when user log in SSH
# save it as /etc/profile.d/ssh-telegram.sh
# use jq to parse JSON from ipinfo.io
# get jq from here http://stedolan.github.io/jq/
USERID="<target_user_id>"
KEY="<bot_private_key>"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %b %Y %H:%M")"
TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt'
if [ -n "$SSH_CLIENT" ]; then
@stevemao
stevemao / np.sh
Last active February 4, 2025 10:08 — forked from sindresorhus/np.sh
Publish node module
# npm publish with goodies
# prerequisites:
# `npm install -g trash conventional-recommended-bump conventional-changelog conventional-github-releaser conventional-commits-detector json`
# `np` with optional argument `patch`/`minor`/`major`/`<version>`
# defaults to conventional-recommended-bump
# and optional argument preset `angular`/ `jquery` ...
# defaults to conventional-commits-detector
np() {
travis status --no-interactive &&
trash node_modules &>/dev/null;
@ajsb85
ajsb85 / firefox-devedition.js
Created June 1, 2015 06:54
Icon button for Firefox devedition theme support
var name = "lightweightThemes.selectedThemeID";
var selectedThemeID = require("sdk/preferences/service").get(name);
var button = ToggleButton({
id: "btcven",
label: "btcven",
icon: {
"16": selectedThemeID === "[email protected]" ? "./icondev16.svg" : "./icon16.svg",
"32": "./icon32.svg",
"64": "./icon64.svg"
@ajsb85
ajsb85 / btcven.json
Created May 31, 2015 18:08
Print example of api.bitcoinvenezuela.com
{
"time": {
"timestamp": 1433094852
},
"BTC": {
"USD": 232.2685,
"EUR": 211.7692,
"VEF": 82216.080945,
"ARS": 2949.80995,
"LTC": "139.86013986",
Components.utils.import("resource://gre/modules/ctypes.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
// Or using Services.jsm and Ci = Components.interfaces
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("CurProcD", Components.interfaces.nsIFile);
// Append the file name.
function usbhid(vendor_id, product_id) {
this.product_id = product_id;
this.vendor_id = vendor_id;
this.buffer_1 = new Object();
this.buffer_2 = new Object();
this.xpcom = Components.classes["@firechip.info/hidapi;1"].createInstance().QueryInterface(Components.interfaces.nsIHid);
this.manufacturer_string = function() {
alert(this.xpcom.manufacturer_string);
}
this.product_string = function() {