Skip to content

Instantly share code, notes, and snippets.

View michaellopez's full-sized avatar

Michael Zetterberg fd. Lopez michaellopez

View GitHub Profile
@michaellopez
michaellopez / README.md
Created December 3, 2020 12:43 — forked from pgib/README.md
Clean up the bloated Backblaze bzfileids.dat

Place in /Library/Backblaze.bzpkg/bzdata/bzbackup, and run with:

ruby purge_nonexistent.rb

It will process bzfileids.dat placing any file that exists in bzfileids.dat-found and any missing file in bzfileids.dat-missing. You can then back up your original file and replace it with bzfileids.dat-found.

My original file was almost 1.4GB. It had grown so large that the backup would cause all my fans spin and it never seemed to complete. Backblaze support suggested I delete my entire backup with them and start over. After running this script, my new bzfileids.dat file is 301MB. Still huge, but about 1/5th the size. The backup seemed to go much more smoothly.

@michaellopez
michaellopez / readme.md
Created December 3, 2020 12:43 — forked from nickcernis/readme.md
Exclude node_modules and .git from Backblaze backups on Mac

Exclude node_modules and .git from Backblaze backups on Mac

  1. Edit the file at /Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml.
  2. Add these rules inside the bzexclusions tag:
<!-- Exclude node_modules. -->
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/node_modules/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/.git/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
@michaellopez
michaellopez / readme.md
Created December 3, 2020 12:43 — forked from jb510/readme.md
Exclude vcs (git, svn, hg) and node_modules from Backblaze backups on Mac

Backblaze's bztransmit process loads a file called bzfileids.dat into RAM. This file is a list of all files Backblaze has previously uploaded, including a unique identifier for each file. On most systems, this files is under 100MB in size (paraphrased from Backblaze support rep Zack).

Mine had grown to 6GB. This means that anytime bztransmit runs, it will load this 6GB file into RAM while it is backing up. In doing so it was purging massive ammounts of memory causing behavior like Chrome (usign 10GB of memory on it's own) to hang/beachball for 30 seconds and then refresh all it's windows.

There is no way to alter this behavior once it's begun, aside from starting over with some files excluded. The index needs to be rebuilt from scratch without the excessibe file count, that also means you can't restart and "inherit" a previous backup.

In my case the biggest culprits were .git and node_modules, so I excluded those, started a new backup (transfered licnese) and spent a week hunting for fast internet I could

@michaellopez
michaellopez / readme.md
Created April 26, 2019 09:07 — forked from astoilkov/readme.md
Async Operations with useReducer Hook

Async Operations with useReducer Hook

We were discussing with @erusev what we can do with async operation when using useReducer() in our application. Our app is simple and we don't want to use a state management library. All our requirements are satisfied with using one root useReducer(). The problem we are facing and don't know how to solve is async operations.

In a discussion with Dan Abramov he recommends Solution 3 but points out that things are fresh with hooks and there could be better ways of handling the problem.

Problem

Doing asynchronous operations in a useReducer reducer is not possible. We have thought of three possible solutions and can't figure which one is better or if there is an even better solution.

@michaellopez
michaellopez / viewsreference_add_entity_to_context-2.patch
Last active April 12, 2018 21:43 — forked from filiphazardous/viewsreference_add_entity_to_context-2.patch
Add nodes in block to context for viewsreference v2
diff --git a/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php b/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
index 7371caf..36252cf 100644
--- a/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
@@ -100,6 +100,9 @@ class ViewsReferenceFieldFormatter extends FormatterBase {
}
$node = \Drupal::routeMatch()->getParameter('node');
+ if ($items->getEntity() instanceof \Drupal\node\NodeInterface) {
+ $node = $items->getEntity();
terminal = require('color-terminal')
log = (error, stdout, stderr, cb) ->
if error
terminal.color('red').write stdout
else
terminal.color('green').write stdout
cb()
@michaellopez
michaellopez / 1 — readme.md
Created May 2, 2014 09:29 — forked from jjb/1 — readme.md
Leave closed Trello
  1. go here and get your Developer Key (ignore that token) https://trello.com/1/appKey/
  2. visit this url, with your Developer Key inserted as shown https://trello.com/1/authorize?key=YOURDEVELOPERKEY&name=My+Application&expiration=1day&response_type=token&scope=read,write
  3. grant access, and then get the token that is produced on the next page
  • You'll need to add a file in the same directory called settings.py that contains strings for MY_KEY, MY_TOKEN, and USER_TOKEN (USER_TOKEN can be an empty string)
  • Run the script with the last line commented out to see what boards you're leaving. When you're ready to do it for real, uncomment the last line.
#!/bin/bash
#
# The reason of creating this script is that Endpoint Security VPN installs it's own application firewall kext cpfw.kext
# which prevents for example PPTP connections from this computer, which is not appropriate if you need subj connection just
# from time to time
# Usage: checkpoint.sh load|unload
# You will need sudo power, of course
#
if [ $1 == "unload" ]