Skip to content

Instantly share code, notes, and snippets.

View alfredrumss's full-sized avatar

Alfredo Rivera alfredrumss

View GitHub Profile
@jarretmoses
jarretmoses / React Native Clear Cache
Last active March 11, 2024 10:20
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
@sgnl
sgnl / postgres-brew.md
Last active April 21, 2024 23:18
Installing Postgres via Brew (OSX) (outdated see top most note)

Outdated note: the process is a lot easier now: after you brew install postgresql you can initialize or stop the daemon with these commands: brew services start postgresql or brew services stop postgresql.

new out put may look like

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start
@josephabrahams
josephabrahams / admin.py
Created May 31, 2015 17:55
Limit number of Django model instances
from django.contrib import admin
from example.models import Example
class ExampleAdmin(admin.ModelAdmin):
"""
Don't allow addition of more than one model instance in Django admin
See: http://stackoverflow.com/a/12469482
"""
def has_add_permission(self, request):
@soukiassianb
soukiassianb / queryset_compare.py
Last active February 19, 2023 10:00
Use python set to compare django querysets
"""
First technique, use set
"""
# two querysets or lists
q1
>>> [<obj1>,<obj2>, <obj3>]
q2
>>> [<obj4>,<obj2>, <obj5>]
# compare querysets :
# Logger specific - good for production
import logging
def config_logger(name='', level=logging.INFO, _format='%(message)s', handler=logging.StreamHandler, propagate=True):
''' configures a logger '''
_handler = handler()
_handler.setFormatter(logging.Formatter(_format))
_logger = logging.getLogger(name)
_logger.addHandler(_handler)
_logger.setLevel(level)
@stkent
stkent / android_studio_shortcuts.md
Last active November 1, 2023 11:58
Android Studio Shortcuts (Mac)

Android Studio Shortcuts (Mac)

Notes:

  • Two of the most useful shortcuts utilize the Fn (function) keys. It is therefore recommended that you enable the "Use all F1, F2, etc. keys as standard function keys" option [System Preferences > Keyboard].
  • Be sure to enable the Mac OS X 10.5+ keymap in Android Studio [Preferences > Keymap].
  • A fairly complete shortcut list can be found here.

Useful symbols:

@eparreno
eparreno / gist:1845561
Created February 16, 2012 15:17
Install libmagic on Mac OS X via homebrew
$ brew install libmagic
$ brew link libmagic (if the link is already created is going to fail, don't worry about that)
$ env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@hyle
hyle / ko.utils.signatures.js
Last active May 14, 2022 21:15
KnockoutJS utils (ko.utils) signatures
// knockout 2.2.1
ko.utils.arrayFilter = function (array, predicate) { /* .. */ }
ko.utils.arrayFirst = function (array, predicate, predicateOwner) { /* .. */ }
ko.utils.arrayForEach = function (array, action) { /* .. */ }
ko.utils.arrayGetDistinctValues = function (array) { /* .. */ }
@jacobian
jacobian / models.py
Created February 15, 2011 18:11
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']
def __unicode__(self):