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" : "Test template for creating a beanstalk environment",
"Parameters" : {
"VPC": {
"Description" : "The AWS VPC to use.",
"Type": "AWS::EC2::VPC::Id"
},
"SubnetA": {
"Description" : "The Subnet in AZ A.",
@nk-gears
nk-gears / cftemplate-eb.json
Created December 21, 2016 15:39 — forked from GeneralistDev/cftemplate-eb.json
Cloud Formation Template (danielparker.com.au) WordPress and Elastic Beanstalk
{
"Outputs":{
"AWSEBLoadBalancerURL":{
"Value":{
"Fn::Join":[
"",
[
"http:\/\/",
{
"Fn::GetAtt":[
{
"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 / 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 / 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");
function processKindleFiles() {
try {
var folderId = "0BwgWw6nnA_fCQW5XQzhtUU00TjQ";
// Get folder by id
var parentFolder = DriveApp.getFolderById(folderId);
var files = parentFolder.getFiles();
while (files.hasNext()) {
var childFile = files.next();
@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 / 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";