Skip to content

Instantly share code, notes, and snippets.

@BobNisco
BobNisco / controller.js
Last active February 27, 2023 15:43
onLongPress AngularJS Directive - Great for mobile!
// Somewhere in your controllers for this given example
// Example functions
$scope.itemOnLongPress = function(id) {
console.log('Long press');
}
$scope.itemOnTouchEnd = function(id) {
console.log('Touch end');
}
@gpstmp
gpstmp / client-side-pseudo-code.js
Created March 31, 2014 19:36
AngularJS: combine REST with Socket.IO
'use strict';
angular.module('app.api.entities.task', ['app.api.rest.task'])
.factory('Task', ['$rootScope', '$q', 'TaskApi', 'Socket', function($rootScope, $q, TaskApi, Socket) {
// here we use a simple in memory cache in order to keep actual data
// you can make it in any other way
var cache = {};
var initObject = function(data) {
if (cache[data._id]) {
# If there is no version tag in git this one will be used
VERSION = 0.1.0
# Need to discard STDERR so get path to NULL device
win32 {
NULL_DEVICE = NUL # Windows doesn't have /dev/null but has NUL
} else {
NULL_DEVICE = /dev/null
}
@jbache
jbache / NavigationDrawer.qml
Created December 1, 2014 15:02
Qt Quick Navigation Drawer
/*
Copyright (c) 2014 Cutehacks A/S
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
import {Injectable, provide} from 'angular2/core';
import {Observable} from 'rxjs';
const GEOLOCATION_ERRORS = {
'errors.location.unsupportedBrowser': 'Browser does not support location services',
'errors.location.permissionDenied': 'You have rejected access to your location',
'errors.location.positionUnavailable': 'Unable to determine your location',
'errors.location.timeout': 'Service timeout has been reached'
};
import {
Directive,
Output,
EventEmitter,
HostBinding,
HostListener
} from 'angular2/core.js';
@Directive({
selector: '[long-press]'
@austriancoder
austriancoder / item.cpp
Created May 2, 2016 07:10
QMetaEnum: Serializing C++ Enums
const QString Item::type() const
{
const QMetaObject &mo = Item::staticMetaObject;
int index = mo.indexOfEnumerator("Type");
QMetaEnum metaEnum = mo.enumerator(index);
return metaEnum.valueToKey(m_type);
}
void Item::setType(const QString &type)
@nrollr
nrollr / nginx.conf
Last active June 9, 2024 23:39
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@EKami
EKami / tf-rasp.md
Last active May 12, 2024 17:11
Building TensorFlow for Raspberry Pi: a Step-By-Step Guide

Building TensorFlow 1.3.0-rc1 for Raspberry Pi/Ubuntu 16.04: a Step-By-Step Guide

Here you'll learn how to build Tensorflow for the raspberry pi 3 with either the Python API or as a standalone shared library which can be interfaced from the C++ API and eventually as a library which can be used in other languages.

For the C++ library this tutorial will show you how extract tensorflow library and headers to use in any environment you want.

(This tutorial couldn't be possible without the help of the people from the References section)

What You Need

#!/bin/bash
function initStaticParams
{
MONGODB_SERVER=127.0.0.1
MONOGDB_PORT=27017
MONGODB_USER=
MONGODB_PWD=
OUTPUT_DIRECTORY=/mnt/backups/oplogs
LOG_FILE="/appl/mongo-backup/logs/backup.log"