Skip to content

Instantly share code, notes, and snippets.

View nk-gears's full-sized avatar
💥
experimenting...

Nirmal nk-gears

💥
experimenting...
View GitHub Profile
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS Quick Start Demo - Elastic Beanstalk App Setup.",
"Parameters" : {
"VPC": {
"Description" : "ID of the VPC to use",
"Type": "String",
"MinLength": "1",
@nk-gears
nk-gears / spring-boot-docker-cfn-sample.cfn.json
Created December 21, 2016 15:46 — forked from wonderb0lt/spring-boot-docker-cfn-sample.cfn.json
The CFN template for the cfn/docker sample
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Infrastructure for the Spring Boot + Docker + CFN sample",
"Parameters": {
"Version": {
"Type": "String",
"Default": "1.0.0"
}
},
"Resources": {
@nk-gears
nk-gears / gist:2db8491655b8e69b94440e84b2d6c0f5
Created January 25, 2017 15:55 — forked from hayderimran7/gist:9246dd195f785cf4783d
How to solve "sudo: no tty present and no askpass program specified" when trying to run a shell from Jenkins
Running shell scripts that have contain sudo commands in them from jenkins might not run as expected. To fix this, follow along
Simple steps:
1. On ubuntu based systems, run " $ sudo visudo "
2. this will open /etc/sudoers file.
3. If your jenkins user is already in that file, then modify to look like this:
jenkins ALL=(ALL) NOPASSWD: ALL
4. save the file by doing Ctrl+O (dont save in tmp file. save in /etc/sudoers, confirm overwrite)
5. Exit by doing Ctrl+X
6. Relaunch your jenkins job
function sendDailyNewsToKindle() {
var todayDate=Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "dd.MM.YY");
var url="http://anynewsite.com/{dt}";
var urlPick=url.replace("{dt}",todayDate);
var response = UrlFetchApp.fetch(urlPick , {});
var todayDateN=Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "dd.MMM.YYYY");
//convert the response to a blob and store in our array
var file1 = response.getBlob().setName(todayDateN + "News.pdf");
@nk-gears
nk-gears / FileDownloadZip.cs
Created July 5, 2017 12:44
Compress and Download Zip
public static void CompressAndDownload(HttpResponseBase _response, string zipFilename, List<FileCompressInfo> files)
{
MemoryStream outputMemStream = new MemoryStream();
ZipOutputStream zipStream = new ZipOutputStream(outputMemStream);
zipStream.SetLevel(3); //0-9, 9 being the highest level of compression
byte[] bytes = null;
foreach (var file in files)
{
@nk-gears
nk-gears / configuration.yaml
Created December 25, 2016 09:12
Configuration.yaml - Home Assistant.io
# I moved this all to https://github.com/CCOSTAN/Home-AssistantConfig - I won't be updating this file anymore.
homeassistant:
name: Bear Stone Run
latitude: !secret homeassistant_latitude
longitude: !secret homeassistant_longitude
elevation: !secret homeassistant_elevation
unit_system: imperial
@nk-gears
nk-gears / async_without_await.cs
Created March 16, 2018 06:08
Async Call without Wait c#
public async Task MyAsyncMethod()
{
// do some stuff async, don't return any data
}
public string GetStringData()
{
// Run async, no warning, exception are catched
RunAsync(MyAsyncMethod());
return "hello world";
@nk-gears
nk-gears / Webhooks-Azure.cs
Last active April 22, 2018 11:52
Add Webhooks to Azure Data Factory
/*
Create a Resource Alert Rule
Map the Rule to a Webhook
Create/Update the Rule
*/
Rule resourceAlertRule = new Rule
@nk-gears
nk-gears / 01-directory-structure.md
Created June 30, 2018 09:13 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@nk-gears
nk-gears / README.md
Created August 25, 2018 05:10 — forked from mill1000/README.md
Headless A2DP Audio Streaming on Raspbian Stretch

About

This gist will show how to setup Raspbian Stretch as a headless Bluetooth A2DP audio sink. This will allow your phone, laptop or other Bluetooth device to play audio wirelessly through a Rasperry Pi.

Motivation

A quick search will turn up a plethora of tutorials on setting up A2DP on the Raspberry Pi. However, I felt this gist was necessary because this solution is:

  • Automatic & Headless - Once setup, the system is entirely automatic. No user iteration is required to pair, connect or start playback. Therefore the Raspberry Pi can be run headless.
  • Simple - This solution has few dependencies, readily available packages and minimal configuration.
  • Up to date - As of December 2017. Written for Raspbian Stretch & Bluez 5.43

Prerequisites