Skip to content

Instantly share code, notes, and snippets.

🎧
Focusing

Dejan Stojanovic dejanstojanovic

🎧
Focusing
Block or report user

Report or block dejanstojanovic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dejanstojanovic
dejanstojanovic / html5.localstorage.ex.js
Created Oct 28, 2018
HTML5 localStorage with expire
View html5.localstorage.ex.js
var localStorageEx = {
get: function (key) {
var value = localStorage[key];
if (value != null) {
var model = JSON.parse(value);
if (model.payload != null && model.expiry != null) {
var now = new Date();
if (now > Date.parse(model.expiry)) {
localStorage.removeItem(key);
return null;
View DirectoryExtensionss.cs
using System.IO;
namespace IOExtensions
{
public static class DirectoryExtensions
{
public static bool IsHidden(this DirectoryInfo dir)
{
return (dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
}
@dejanstojanovic
dejanstojanovic / k8-service
Created Sep 6, 2018
k8 service commands and config
View k8-service
=================== M6-03
### Wrapping the hello-rc Replication Controller in a Service - the iterative way
$ kubectl expose rc hello-rc --name=hello.svc --target-port=800 --type=NodePort
$ kubectl describe svc hello-svc
=================== M6-04
### Wrapping the hello-rc Replication Controller in a Service - the iterative way
@dejanstojanovic
dejanstojanovic / k8-deployment
Created Sep 6, 2018
k8 deployment config and commands
View k8-deployment
#### m7-03
kubectl delete rc hello-rc
kubectl get pods
kubectl describe svc hello-svc
vim deploy.yml
kubectl create deployment
@dejanstojanovic
dejanstojanovic / read-file-lines.sh
Created Aug 28, 2018
Read text file line by line via bash
View read-file-lines.sh
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
echo $line
done < "$1"
View Windows-Linux-TimeZone.json
[
{
"Windows": "Dateline Standard Time",
"Linux": "Etc/GMT+12"
},
{
"Windows": "UTC-11",
"Linux": "Etc/GMT+11"
},
{
View JavaScriptUtc.js
var today = new Date();
var todayUtc = new Date(today.getUTCFullYear(),today.getUTCMonth(),today.getUTCDay(),today.getUTCHours(),today.getUTCMinutes(),today.getUTCSeconds(), today.getUTCMilliseconds());
console.log(today.toString());
console.log(todayUtc.toString());
View StackExchange.Redis-ExpiryCounters.cs
class Program
{
static ConnectionMultiplexer redisConnection = ConnectionMultiplexer.Connect("<REDIS connection string>");
static void Main(string[] args)
{
var key = "counter.test";
var expiry = TimeSpan.FromMinutes(5);
IDatabase db = redisConnection.GetDatabase(3);
var count = db.StringIncrement(key, 1);
@dejanstojanovic
dejanstojanovic / CreateIISSite
Last active Jan 16, 2018 — forked from ifrahim/CreateIISSite
Create IIS Site using Powershell
View CreateIISSite
#unzip -> https://stackoverflow.com/questions/27768303/how-to-unzip-a-file-in-powershell
#check -> http://geekswithblogs.net/QuandaryPhase/archive/2013/02/24/create-iis-app-pool-and-site-with-windows-powershell.aspx
#check -> https://docs.microsoft.com/en-us/iis/manage/powershell/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools
# The following code will create an IIS site and it associated Application Pool.
# Please note that you will be required to run PS with elevated permissions.
# Visit http://ifrahimblog.wordpress.com/2014/02/26/run-powershell-elevated-permissions-import-iis-module/
@dejanstojanovic
dejanstojanovic / mbrola-pi-setup.sh
Last active Oct 12, 2017 — forked from sourceperl/setup.sh
Text to speak software with espeak and mbrola for Raspberry Pi2 (under Raspbian/jessie)
View mbrola-pi-setup.sh
# install espeak
sudo apt-get install espeak
# install mbrola
wget http://tcts.fpms.ac.be/synthesis/mbrola/bin/raspberri_pi/mbrola.tgz
tar xvzf mbrola.tgz
chmod 755 mbrola
sudo mv ./mbrola /usr/local/bin/
# install voices for mbrola
You can’t perform that action at this time.