Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

provider "google" {
region = "${var.region}"
project = "${var.project_name}"
credentials = "${file("${var.credentials_file_path}")}"
}
resource "google_compute_instance" "docker" {
count = 1
google_compute_instance.docker[0]: Creating...
google_compute_instance.docker[0]: Still creating... [10s elapsed]
google_compute_instance.docker[0]: Still creating... [20s elapsed]
google_compute_instance.docker[0]: Provisioning with 'remote-exec'...


Error: Failed to parse ssh private key: ssh: cannot decode encrypted private keys
@janosgyerik
janosgyerik / 732-my-calendar-3.java
Created March 11, 2019 19:54
732. My Calendar III
// solution to: 732. My Calendar III https://leetcode.com/problems/my-calendar-iii/
class MyCalendarThree {
private final Comparator<Pos> comparator = Comparator.<Pos>comparingInt(p -> p.pos)
.thenComparing((p1, p2) -> {
if (p1.mark == p2.mark) return Integer.compare(p1.hashCode(), p2.hashCode());
if (p1.mark == Mark.END) return -1;
return 1;
});
private final SortedSet<Pos> marks = new TreeSet<>(comparator);

Create Amazon EC2 Instance

  • Ensure that inbound MySQL port 3306 is opened
  • chmod 700 "keypair-name.pem"

Install MySQL

To install MySQL, run the following command from a terminal prompt:

  • sudo apt-get install mysql-server
library(rtweet)
D <- c()
for(u in c("OneNaziq", "AzimRidzuan_", "pais_10")) {
D <- rbind(D, get_followers(u, n= "all", page = "-1", parse = TRUE, as_double = FALSE, token = NULL))
}
nrow(D)
@janosgyerik
janosgyerik / only-vim-can-do.md
Last active December 24, 2016 04:15
Things only Vim can do easily
  1. Works even under the most spartan conditions (in a simple remote shell window such as xterm, putty), with syntax highlighting, function folding, tabs, buffers, and all that lightning fast
  2. Delete lines matching pattern: g/pattern/d
  3. Delete lines not matching pattern: g!/pattern/d
  4. Sort buffer: :%sort
  5. Filter buffer through command :%!sort -u
  6. Delete from current line until end of file (try with a large file!)
  7. Increment numeric values: C-a, C-x
  8. Complete line pattern C-x C-l
  9. Convert a DOS file (with CRLF line endings) to UNIX: :set ff=unix (and then save it)

Java:

@POST
@Path("/post")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response createPost(@FormParam("type") String type,  @FormParam("content") String content) { 
    postEJB.createPostUserRest(type, content);
    URI userURI = uriInfo.getAbsolutePathBuilder().build();
    return Response.created(userURI).build();

}

@janosgyerik
janosgyerik / dump-foursquare-categories.py
Created June 10, 2012 19:05
Dump foursquare categories to a file in JSON format
#!/usr/bin/env python
#
# Notes:
#
# - python API home:
# https://github.com/mLewisLogic/foursquare
#
# - foursquare API home:
# https://developer.foursquare.com/
#
@janosgyerik
janosgyerik / post-receive
Last active November 2, 2016 06:57
A post-receive hook that runs a script if changes were pushed to a specific branch. (Hook scripts are in the hooks/ directory of a Git repository, and must be executable.)
#!/bin/sh
# 1. Create symlinks to the real upgrade scripts for each branch, for example:
# ./upgrade-beta.sh # will only be called when "beta" branch is updated
# ./upgrade-prod.sh # will only be called when "prod" branch is updated
#
# 2. Put these symlinks in the repository root, NOT in the hooks/ directory
# the post-receive hook receives parameters on stdin
while read oldrev newrev refname