Skip to content

Instantly share code, notes, and snippets.

View milanaleksic's full-sized avatar

Milan Aleksić milanaleksic

View GitHub Profile
@milanaleksic
milanaleksic / gmail.py
Last active November 24, 2023 15:23
Download GMAILFS email attachments from Gmail
# NOTE: Gmail doesn't allow usage of service accounts for _personal GMail accounts_, you need OAuth client key
import base64
import json
import logging
import os.path
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
@milanaleksic
milanaleksic / functions.sh
Created May 12, 2017 08:45
List all known functions
# as long as your functions are located in files mentioned in the "in" clause of the for below
# and as long as functions are following the same pattern of "function_name() {" with a single comment above,
# the function below will list them all in a nice way
# lists all known functions
functions() {
for f in ~/.dockerfunc ~/.functions ~/bash/.extra_*
do
@milanaleksic
milanaleksic / index.js
Created July 11, 2016 09:44
Simple Lambda for checking the Site uptime
'use strict';
var aws = require('aws-sdk');
var https = require('https');
var ses = new aws.SES();
var processingContext = {
noOfSuccesses: 0,
failures: [],
endpoints: [
@milanaleksic
milanaleksic / ngrok_port.go
Last active March 3, 2023 16:26
Ngrok free mode always has only one single tunnel allowed. If you use TCP tunnel, this script extracts the value (since ngrok doesn't have server API). This way you can connect to that port from a script (ssh tunnel is my favorite usage of ngrok) instead of having to visit the site manually to get this value.
package main
import (
"bufio"
"errors"
"fmt"
"io"
"log"
"net/http"
"net/http/cookiejar"

Keybase proof

I hereby claim:

  • I am milanaleksic on github.
  • I am milanaleksic (https://keybase.io/milanaleksic) on keybase.
  • I have a public key whose fingerprint is DF46 6544 CFD4 69A5 4FA0 1F6A D92A 3E9D 70AC 479D

To claim this, I am signing this object:

@milanaleksic
milanaleksic / books.md
Last active March 21, 2024 17:42
Locus All Century Best SF/Fantasy Books (based on http://www.locusmag.com/2012/AllCenturyPollsResults.html)

20th Century SF Novel

Rank Author : Title (Year)

  • Herbert, Frank : Dune (1965)
  • Card, Orson Scott : Ender's Game (1985)
  • Asimov, Isaac : The Foundation Trilogy (1953)
  • Simmons, Dan : Hyperion (1989)
  • Le Guin, Ursula K. : The Left Hand of Darkness (1969)
  • Adams, Douglas : The Hitchhiker's Guide to the Galaxy (1979)
  • Orwell, George : Nineteen Eighty-Four (1949)
  • Gibson, William : Neuromancer (1984)
@milanaleksic
milanaleksic / count_restarts.sh
Last active December 16, 2015 08:09
Count number of lines in log per day with specific string (good found counting number of server restarts for example)
#!/bin/bash
perl -e 'use POSIX qw(strftime); $i=0; while($i<10) { $dt=strftime "%Y-%m-%d",localtime(time()- 3600*$i*24); print $dt.": "; print `cat server.log | grep "server restarted" | grep -c "$dt"`; $i++; }'
@milanaleksic
milanaleksic / MyForm.gui
Last active October 4, 2015 22:27
Source of example snippets used in SWT Gui Transformer page: http://milanaleksic.github.com/swt-gui-transformer/
{
"_type" : "shell",
"_style" : "{dialog_trim}",
"_name" : "myFormShell",
"text" : "[title]",
"size" : "300,120",
"layout" : {
"_type" : "gridLayout",
"numColumns" : 2
},
@milanaleksic
milanaleksic / FindBadURLsInChromeBookmarks.groovy
Created January 6, 2012 14:58
Find bad URLs in exported Chrome bookmarks file
package misc
String bookmarksFile = 'c:/temp/bookmarks.html'
def counter = new java.util.concurrent.atomic.AtomicInteger(0)
Map<String, String> urls = [:]
Map<String, String> badURLs = [:]
new File(bookmarksFile).eachLine { line ->
(line =~ /(?i)<A HREF="([^"]+)"[^>]*>([^<]*)<.*/).each { entire, linkLocation, linkName ->
@milanaleksic
milanaleksic / ImdbProposeFilmName.groovy
Created July 3, 2011 22:01
Fetching possible IMDB titles based on search phrase
package misc
import groovy.json.JsonSlurper
// Pretraga za "Bat" gadja naredni URL: http://sg.media-imdb.com/suggests/b/bat.json
def getMatchesForInput(input) {
String content
try {
InputStream stream = new URL("http://sg.media-imdb.com/suggests/${input[0]}/${input}.json").openStream()