Skip to content

Instantly share code, notes, and snippets.

View Jaimies's full-sized avatar

Max Poliakov Jaimies

View GitHub Profile
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git
@ikew0ng
ikew0ng / ClearBackStack.java
Created January 7, 2014 09:41
Clear fragment backStack
/**
* Remove all entries from the backStack of this fragmentManager.
*
* @param fragmentManager the fragmentManager to clear.
*/
private void clearBackStack(FragmentManager fragmentManager) {
if (fragmentManager.getBackStackEntryCount() > 0) {
FragmentManager.BackStackEntry entry = fragmentManager.getBackStackEntryAt(0);
mFragmentManager.popBackStack(entry.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
@wpscholar
wpscholar / vagrant-cheat-sheet.md
Last active April 15, 2025 07:44
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@karayok
karayok / screenSize.kt
Created January 17, 2018 10:47
Get screen size (Android/Kotlin)
// import android.content.Context.WINDOW_SERVICE
// import android.view.WindowManager
// import android.graphics.Point
// privat val size by lazy {
private val size = {
Point().also {
(context.getSystemService(WINDOW_SERVICE) as WindowManager)
.defaultDisplay
@NewEXE
NewEXE / parser.php
Last active November 30, 2021 08:25
LoveRead.ec parser (PHP)
<?php
/**
* Book ID on loveread.ec
* For example, for
* http://loveread.ec/read_book.php?id=2555&p=1
* ID is 2555.
*
* @param int $id
*/
public function getFromLoveread(int $id) {
@robmathers
robmathers / groupBy.js
Created October 25, 2018 23:18
A more readable and annotated version of the Javascript groupBy from Ceasar Bautista (https://stackoverflow.com/a/34890276/1376063)
var groupBy = function(data, key) { // `data` is an array of objects, `key` is the key (or property accessor) to group by
// reduce runs this anonymous function on each element of `data` (the `item` parameter,
// returning the `storage` parameter at the end
return data.reduce(function(storage, item) {
// get the first instance of the key by which we're grouping
var group = item[key];
// set `storage` for this instance of group to the outer scope (if not empty) or initialize it
storage[group] = storage[group] || [];
@DenisBronx
DenisBronx / ListMapper.kt
Last active November 8, 2023 20:08
Repository Pattern ListMapper
// Non-nullable to Non-nullable
interface ListMapper<I, O>: Mapper<List<I>, List<O>>
class ListMapperImpl<I, O>(
private val mapper: Mapper<I, O>
) : ListMapper<I, O> {
override fun map(input: List<I>): List<O> {
return input.map { mapper.map(it) }
}
}