Skip to content

Instantly share code, notes, and snippets.

@winadiw
winadiw / Elastic REST Basics of Indexing.MD
Last active June 24, 2020 11:12
Elasticsearch REST Cheat Sheet
@winadiw
winadiw / app.js
Created June 1, 2020 07:51 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
$ git remote rm origin
$ git remote add origin git@github.com:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master
@winadiw
winadiw / podspec-example
Created March 14, 2019 11:54 — forked from atereshkov/podspec-example
Xcode 10 Fat framework - How to create universal binary iOS framework (+ Cocoapods podspec)
If you've got something like this:
file was built for arm64 which is not the architecture being linked (x86_64):
Than this gist is for you.
Let's say you have already developed the framework itself and just want to build the binary
and distribute it through the Cocoapods.
1. Make sure your framework "Deployment Target" is equal to all the dependencies from your podspec file.
@winadiw
winadiw / MyApp.java
Created January 9, 2019 10:16 — forked from artem-zinnatullin/MyApp.java
If you need to set one font for all TextViews in android application you can use this solution. It will override ALL TextView's typefaces, includes action bar and other standard components, but EditText's password font won't be overriden.
public class MyApp extends Application {
@Override
public void onCreate() {
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
}
}
@winadiw
winadiw / gist:6b4561803eac7aa547600ebb17816952
Created December 10, 2018 14:46 — forked from evildmp/gist:3094281
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@winadiw
winadiw / django_deploy.md
Created November 18, 2018 14:30 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@winadiw
winadiw / django_cheat_sheet.md
Last active November 18, 2018 14:31 — forked from bradtraversy/django_cheat_sheet.md
Django command cheat sheet

Django 2.x Cheat Sheet

Creating a virtual environment

We need to create a virtual env for our app to run in: More Here Run this command in whatever folder you want to create your venv folder

python3 -m venv ./venv

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@winadiw
winadiw / postgres-cheatsheet.md
Created September 10, 2018 05:49 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)