class Time
# Convert a time that is 'milliseconds since epoch' to a Time object
#
# @return [Time] A time object created from a 'milliseconds since epoch' timestamp
def self.from_millisecond_epoch time
Time.at(time / 1000)
end
View checksum.c
#include <stdio.h> | |
#include <stdint.h> | |
typedef uint32_t DWORD; | |
typedef uint16_t WORD; | |
int main(int argc, char *argv[]) { | |
char *filename = "firmware.bin"; | |
FILE *input_file; |
View artifactory_integration_test.sh
#!/bin/bash | |
## Setup a VM | |
vagrant init ubuntu/xenial64 | |
vagrant up | |
## Install OpenJDK 8 | |
sudo add-apt-repository ppa:rpardini/adoptopenjdk | |
sudo apt-get update | |
sudo apt-get install adoptopenjdk-8-jdk-hotspot-set-default |
View repo_backup.sh
#!/bin/bash | |
set -e | |
BUNDLE_NAME=${1} | |
: "${BUNDLE_NAME:?Name of the bundle file should be the first argument.}" | |
REPO_URL=${2} | |
: "${REPO_URL:?URL of the repo to clone should be the second argument.}" | |
BUNDLE_FILE=$(pwd)/${BUNDLE_NAME}.bundle |
View gist:bf01655381cd6ae1f587abc249c0ea73
### Keybase proof | |
I hereby claim: | |
* I am flyinprogrammer on github. | |
* I am flyinprogrammer (https://keybase.io/flyinprogrammer) on keybase. | |
* I have a public key ASBHVn2EEKCZ3NNvX-HgR6R95K7snb_xPI-GZTG9fTyixQo | |
To claim this, I am signing this object: |
View install_hashicorp.sh
#!/usr/bin/env bash | |
set -e | |
CONSUL_VERSION=1.0.3 | |
NOMAD_VERSION=0.7.1 | |
VAULT_VERSION=0.9.3 | |
TERRAFORM_VERSION=0.11.2 | |
PACKER_VERSION=1.1.3 | |
tee hashicorp.asc <<EOF |
View cloud-init.bash
## Step 1) install/ensure sysfsutils is installed | |
sudo apt-get install sysfsutils | |
# --------------------------------- | |
# Manage /sys filesystem. Requires sysfsutils package | |
## Turn off THP | |
sudo tee -a /etc/sysfs.d/thp.conf <<-EOF | |
kernel/mm/transparent_hugepage/enabled = never | |
kernel/mm/transparent_hugepage/khugepaged/defrag = 0 |
View clean.sh
#!/bin/bash | |
# Unmount project | |
umount /vagrant | |
# Tell installer to keep en_US | |
echo en_US > /etc/locale.gen | |
# Install localepurge - NO dpkg | |
apt-get install -y localepurge | |
localepurge | |
apt-get remove -y pollinate overlayroot fonts-ubuntu-font-family-console cloud-init python-apport landscape-client juju chef open-vm-tools localepurge |
View dup2_ex1_4.go
// dup2 | |
// | |
// Prints the count and text of the lines that appear more than once in the input. | |
// It reads from stdin or from a list of named files. | |
// | |
// The original version simply printed the line and total count across all inputs. | |
// The exercise asked you to modify it to print all the anmes of the files in which | |
// each duplicated line occurs. | |
// | |
package main |
View jruby_time_bug.md
View gist:4490672
#!/usr/bin/env ruby | |
require 'date' | |
require 'mongoid' | |
Mongoid::Config.connect_to("email_test") | |
class Email | |
include Mongoid::Document | |
field :headers | |
field :received |
NewerOlder