Skip to content

Instantly share code, notes, and snippets.

View grahamcrowell's full-sized avatar

Graham Crowell grahamcrowell

  • Toronto ON Canada
View GitHub Profile
@gerwin3
gerwin3 / make-vcard.py
Created January 23, 2021 16:16
Generate vCard using Python
"""
This little script can generate a valid .vcf (vCard). It will ask you to fill
in some details and write the vcf-file.
"""
def main():
print('Please enter contact details:')
first_name = input(' - First name : ')
last_name = input(' - Last name : ')
email = input(' - E-mail address : ')
@ricardozanini
ricardozanini / how-to-install-graalvm-linux.md
Last active February 22, 2024 20:59
How to install GraalVM on Linux with alternatives

How to Install GraalVM Community Edition on Linux

Note: Tested on Fedora only

  1. Download the new release of GraalVM and unpack it anywhere in your filesystem:
$ tar -xvzf graalvm-ce-1.0.0-rc14-linux-amd64.tar.gz
@grahamcrowell
grahamcrowell / colorlog.py
Last active March 1, 2024 05:29
python snippet for coloured logging
def config_color_logging():
"""Configure and return a colored console logger.
see https://github.com/borntyping/python-colorlog#usage
see https://docs.python.org/3/library/logging.html#logrecord-attributes
:return: logger
"""
import colorlog

WannaCry|WannaDecrypt0r NSA-Cyberweapon-Powered Ransomware Worm

  • Virus Name: WannaCrypt, WannaCry, WanaCrypt0r, WCrypt, WCRY
  • Vector: All Windows versions before Windows 10 are vulnerable if not patched for MS-17-010. It uses EternalBlue MS17-010 to propagate.
  • Ransom: between $300 to $600. There is code to 'rm' (delete) files in the virus. Seems to reset if the virus crashes.
  • Backdooring: The worm loops through every RDP session on a system to run the ransomware as that user. It also installs the DOUBLEPULSAR backdoor. It corrupts shadow volumes to make recovery harder. (source: malwarebytes)
  • Kill switch: If the website www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com is up the virus exits instead of infecting the host. (source: malwarebytes). This domain has been sinkholed, stopping the spread of the worm. Will not work if proxied (source).

update: A minor variant of the viru

@thomasdarimont
thomasdarimont / readme.md
Last active May 20, 2024 22:58
Example for decoding a JWT Payload with your Shell (bash, zsh...)

Setup

Add this to your .profile, .bashrc, .zshrc...

decode_base64_url() {
  local len=$((${#1} % 4))
  local result="$1"
  if [ $len -eq 2 ]; then result="$1"'=='
  elif [ $len -eq 3 ]; then result="$1"'=' 
  fi
 echo "$result" | tr '_-' '/+' | openssl enc -d -base64
@ozzieliu
ozzieliu / calling_stubhub_api.py
Last active September 9, 2023 16:56
Proof of Concept task to get ticket prices and event info using StubHub's API with Python
# Quick intro to accessing Stubhub API with Python
# Ozzie Liu (ozzie@ozzieliu.com)
# Related blog post: http://ozzieliu.com/2016/06/21/scraping-ticket-data-with-stubhub-api/
# Updated 3/5/2017 for Python 3 and Stubhub's InventorySearchAPI - v2
import requests
import base64
import json
import pprint
import pandas as pd
@jwgmeligmeyling
jwgmeligmeyling / DatabaseTestModule.java
Created May 18, 2016 22:19
Persisting recursive relationships with Hibernate
package org.hibernate.test;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.persist.PersistService;
import com.google.inject.persist.jpa.JpaPersistModule;
public class DatabaseTestModule extends AbstractModule {
@lloydmeta
lloydmeta / AkkaStreamSparkIntegration.scala
Last active January 28, 2021 17:11
Example for how to connect Akka Stream and Spark Streaming by turning creating a Flow element that feeds into an InputDstream
import akka.actor._
import akka.stream.scaladsl.Flow
import org.apache.spark.streaming.dstream.ReceiverInputDStream
import org.apache.spark.streaming.receiver.ActorHelper
import akka.actor.{ ExtensionKey, Extension, ExtendedActorSystem }
import scala.reflect.ClassTag
object AkkaStreamSparkIntegration {

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o

@vidavidorra
vidavidorra / auto-deploy_documentation.md
Last active June 5, 2024 19:20
Auto-deploying Doxygen documentation to gh-pages with Travis CI

Auto-deploying Doxygen documentation to gh-pages with Travis CI

This explains how to setup for GitHub projects which automatically generates Doxygen code documentation and publishes the documentation to the gh-pages branch using Travis CI. This way only the source files need to be pushed to GitHub and the gh-pages branch is automatically updated with the generated Doxygen documentation.

Sign up for Travis CI and add your project

Get an account at Travis CI. Turn on Travis for your repository in question, using the Travis control panel.

Create a clean gh-pages branch

To create a clean gh-pages branch, with no commit history, from the master branch enter the code below in the Git Shell. This will create a gh-pages branch with one file, the README.md in it. It doesn't really matter what file is uploaded in it since it will be overwritten when the automatically generated documentation is published to th