Skip to content

Instantly share code, notes, and snippets.

import java.util.Arrays;
import java.util.List;
import javax.transaction.Synchronization;
import org.apache.commons.lang.Validate;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.context.internal.ManagedSessionContext;
@krimple
krimple / README.md
Last active June 7, 2018 15:37
Test and class under test for Http mocking - Angular 2 beta 1

This snippet is a working example of a test against the Http service in Angular 2.0.

It is a very simple test, and provides an example of how to:

  • Provide the right wiring to the test injector
  • Inject the fake XHRBackend (i.e. MockBackend)
  • Define a potential request
  • Run the request in the framework
  • Set expectations on the result
@huberflores
huberflores / tsungconf.as
Last active August 26, 2018 11:51
Tsung installation and Cluster Configuration
/*
* author Huber Flores
*/
# Install on each Node
$ su
# Perl Templating-Toolkit and the Gnu plotting utility to create HTML and graphical reports with the result data set.
$ apt-get install gnuplot-nox libtemplate-perl libhtml-template-perl libhtml-template-expr-perl
@zeroeth
zeroeth / check_out_active.sh
Created August 20, 2012 16:30
Jurassic Park movie source code
# CheckOutActive - Check the active window out for modification
#
# Usage: Called by a user­defined menu item
#
# CheckOutActive uses the ProjectInfo command to determine the
# parent project for the file open as the Active window. Once this
# project has been determined, the file open as the Active window
# can be properly checked out.
#
# © Apple Computer, Inc. 1988
@kurtmilam
kurtmilam / deep_extend_javascript_objects_underscore_mixin.js
Last active October 3, 2020 14:56
Deep Extend / Merge Javascript Objects - underscore.js Mixin
/* Copyright (C) 2012-2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* This mixin now has its own github repository: https://github.com/kurtmilam/underscoreDeepExtend
* It's also available through npm and bower
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFR
@wkwiatek
wkwiatek / app-1.spec.ts
Last active December 17, 2021 01:52
Angular 2 test snippets for Angular final version. Codebase for https://developers.livechatinc.com/blog/category/programming/angular-2/
// App
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: '<span>{{ sayHello() }}</span>',
})
export class App {
public name: string = 'John';
@stefansundin
stefansundin / extract-attachments.py
Last active September 27, 2022 18:54
Extract attachments from emails that Gmail doesn't allow you to download. This is dumb. Please use Python >= 3.4.
#!/usr/bin/env python3
# Get your files that Gmail block. Warning message:
# "Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled."
# Based on: https://spapas.github.io/2014/10/23/retrieve-gmail-blocked-attachments/
# Instructions:
# Go to your emails, click the arrow button in the top right, "Show original", then "Download Original".
# Move the files to the same directory as this program, then run it.
import sys
@dixson3
dixson3 / workspace.sh
Created January 10, 2014 19:11
Create and manage a case-sensitive disk-image on OSX. This is great when you have a need to work with case-sensitive repos on a mac.
#!/bin/bash
# where to store the sparse-image
WORKSPACE=~/Documents/workspace.dmg.sparseimage
create() {
hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 60g -volname workspace ${WORKSPACE}
}
detach() {
@customcommander
customcommander / browser_logs-chrome.js
Created May 25, 2017 09:13
Capture console.log() output from a web page with Selenium WebDriver 2.53 and Chrome
require('chromedriver');
const path = require('path');
const wd = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
var builder = new wd.Builder();
var options = new chrome.Options();
var prefs = new wd.logging.Preferences();
var driver;
@patik
patik / how-to-squash-commits-in-git.md
Last active October 17, 2023 02:19
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date: