Skip to content

Instantly share code, notes, and snippets.

View arvindr21's full-sized avatar
💭
Meh

Arvind Ravulavaru arvindr21

💭
Meh
View GitHub Profile
@niemyjski
niemyjski / description.md
Last active June 8, 2023 15:33
Report Home Assistant Battery Levels With Node-RED

I decided to share this snippet based on seeing what others were doing in this thread: https://www.reddit.com/r/homeassistant/comments/emvk9y/how_do_you_monitor_sensor_battery_levels_looking/

Basically dome device types of battery report the state in different locations and with different string values that the change node or conditional logic just doesn't work nicely. Using the conditional logic on this string state value might not be working fully how we think it is or at least didn't for me. When I was debugging it and getting 10 outputted in a 100 bucket via the gt condition. The best way I've found to handle these conditions is with a function node.

Home Assistant Feedback

@devinsays
devinsays / example-ajax-enqueue.php
Last active October 4, 2023 13:09
Simple WordPress Ajax Example
<?php
function example_ajax_enqueue() {
// Enqueue javascript on the frontend.
wp_enqueue_script(
'example-ajax-script',
get_template_directory_uri() . '/js/simple-ajax-example.js',
array( 'jquery' )
);
@kn9ts
kn9ts / inAppBrowserExample.js
Last active August 6, 2020 02:35
An InAppBrowser instance example
var browser = cordova.InAppBrowser.open('http://amazon.com?vitumob_session_id=13279njke12hjhuidhiush124hu', '_blank', 'location=no');
browser.addEventListener('loadstart', function(event) {
alert('Began loading this page: ' + JSON.stringify(event));
});
// event fires when the InAppBrowser finishes loading a URL.
browser.addEventListener('loadstop', function(event) {
// event => {type: 'loadstop', url: 'URL navigated to'}
// alert('InAppBrowser Event: ' + JSON.stringify(event));
@garycrawford
garycrawford / docker-compose.yml
Created July 9, 2015 13:00
MongoDB Replica Set docker-compose.yml
primary:
image: mongo:3.0
volumes:
- ./p:/data
ports:
- "27017:27017"
# Our current version of docker-compose doesn't allow extra_hosts which would be the best way
# to add curcular dependency container links in this case. We cant upgrade docker-compose
# without upgrading docker to 1.7, and we can't do that without upgrading the kernel on our
# CentOS VM's. As such we are using the hostname hask below to allow primary and secondary
@adon-at-work
adon-at-work / multer-to-s3.js
Last active April 3, 2023 18:10
Sample File Upload From Multer to S3
var AWS = require('aws-sdk'),
fs = require('fs');
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Disk
AWS.config.loadFromPath('./aws-config.json');
// assume you already have the S3 Bucket created, and it is called ierg4210-shopxx-photos
var photoBucket = new AWS.S3({params: {Bucket: 'ierg4210-shopxx-photos'}});
function uploadToS3(file, destFileName, callback) {
@Lochlan
Lochlan / trigger-change-file-input
Created February 23, 2015 07:48
This is how you trigger a `change` event on `<input type="file">` with JavaScript — useful for testing!
// vanilla JS
var event = document.createEvent("UIEvents");
event.initUIEvent("change", true, true);
document.querySelector('input[type=file]').dispatchEvent(event);
// jQuery
$('input[type=file]').trigger('change');
@ericelliott
ericelliott / essential-javascript-links.md
Last active April 22, 2024 10:15
Essential JavaScript Links
@ghalusa
ghalusa / default
Last active March 7, 2023 12:17
nginx default configuration file (ubuntu path: /etc/nginx/sites-available/default) with conversions of .htaccess environment variables and mod_rewrite logic, along with parameters supporting a fastcgi-based php setup
server {
listen 80;
root /var/www/YOUR_DIRECTORY;
index index.php index.html index.htm;
###################################################
# Change "yoururl.com" to your host name
server_name yoururl.com;
<!--
-
- The below code will convert a ng-repeat which display 3 column like
- 1 | 2 | 3
- 4 | 5 | 6
- 7 | 8 | 9
- 10
- To
-
- 1 | 5 | 8
@abeisgoat
abeisgoat / ImageUpload.js
Last active January 30, 2020 15:54
An example of image uploading using Firebase with AngularFire.
angular.module('app')
.controller('ImageUpload', ['$scope', '$log',
function ImageUpload($scope, $log) {
$scope.upload_image = function (image) {
if (!image.valid) return;
var imagesRef, safename, imageUpload;
image.isUploading = true;
imageUpload = {