Skip to content

Instantly share code, notes, and snippets.

@davidsanguinetti
davidsanguinetti / MonthYear.java
Created Oct 14, 2019
Util casse, to manage Dates, and misc stuff
View MonthYear.java
/**
* Month/Year auxiliar class
* Recomendation: 0 - January -- Just like the Calendar class
*/
public class MonthYear {
private int month,
year;
public MonthYear(int month, int year) {
this.month = month;
View ingress-prod.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
... your annotations here
name: prod-nginx
labels:
env: prod
namespace: prod
spec:
View all_sorts_of_sorts.md

Stable vs unstable

stable: keys always remain in the same order after sorting equal values

Before:
key:0  1  2  3
   [3][0][2][2]
   
After:
key:0  1  2  3
   [0][2][2][3]
View 4_v3.rb
require 'csv'
require 'ostruct'
doc = "movies.txt"
syms = [:link, :title, :year, :country,
:date, :genre, :duration,
:rating, :director, :stars]
mas = CSV.readlines(doc, headers: syms, col_sep: "|").map{|unit| OpenStruct.new(unit.to_h)}
@Se7enSquared
Se7enSquared / pycarddeck.py
Created Oct 14, 2019
[Python deck of cards example] deck of cards implementing dunder len and getitem with named tuples
View pycarddeck.py
import collections
Card = collections.namedtuple('Card', ['rank', 'suit'])
class FrenchDeck:
ranks = [str(n) for n in range(2, 11)] + list('JQKA')
suits = 'spades diamonds clubs hearts'.split()
def __init__(self):
self._cards = [Card(rank, suit) for suit in self.suits
View medium-article-vue-gridview-2.html
<div id="app-gridview">
<div>
<button class="button"><span>Switch to ListView</span></button>
<button class="button"><span>Switch to books data</span></button>
</div>
<div class="grid-wrapper">
<div class="grid-row">
@ekiara
ekiara / gist:a17d014d951bc31b714179e6cc6432b4
Created Oct 14, 2019
make-django-user-a-superuser-in-shell
View gist:a17d014d951bc31b714179e6cc6432b4
# To make a user a superuser in Django via the shell
from django.contrib.auth.models import User
user = User.objects.filter(username="the_username").first()
user.is_staff = True
user.is_superuser = True
user.save()
@jpweist
jpweist / jQuery-get-set-content
Created Oct 14, 2019
jQuery Getting and Setting Content
View jQuery-get-set-content
# Getting and Setting Content
For all applicable questions, compare and contrast using jQuery and vanilla JS.
- How do you get the text from an element (like a paragraph) with jQuery??
jQuery | text() Method .html
This method is used to set or return the text content of the element.
While setting the content, it overwrites the content of all the matched elements.
The returned content of text method() is used to return the text content of all matched elements.
- How do you set the text of an element (like a paragraph)?
@lbussy
lbussy / Raspberry Pi OTG WAP.md
Created Oct 14, 2019
How to create a Wireless Access Point with a, OTG connected Raspberry Pi to share your Internet Connection
View Raspberry Pi OTG WAP.md

Creating a Raspberry Pi Wireless Access Point Bridge (WAP) via On The Go (OTG) Connection

Issue: You are travelling and all oyu have access to is that crappy sort of Internet which requires you to hit a network login page via your laptop's web browser. You want to connect some other devices, maybe some IoT devices so you can keep up with your projects. No way to do that since they don't have a web browser. Or maybe you have access to some pay-as-you-go Internet but it only allows one device?

Solution: A Raspberry Pi Zero W (or any Pi with a WiFi).

Overview:

  1. The Raspberry Pi is connected to your computer's USB port and use what's called a Remote Network Driver Interface Specification (RNDIS) adapter to create a network between your Pi and your computer over the USB.
  2. Your main computer's network connections is then shared, allowing another network connection to use its Internet connection.
View complex-traverse.js
function traverseObject(obj, replaceWhenCycle, visited = new Set(), traversalKey) {
Object.keys(obj).reduce((acc, key) => {
if (visited.has(key)) {
return {
...acc,
[key]: replaceWhenCycle(obj[key]),
}
}
else if (Array.isArray(obj[key]) {
visited.add(key);
You can’t perform that action at this time.