Skip to content

Instantly share code, notes, and snippets.

View timonweb's full-sized avatar

Tim Kamanin timonweb

View GitHub Profile
@timonweb
timonweb / tasks.sh
Last active June 18, 2020 12:47
Tasks launcher
#!/bin/sh
#
# One line installer:
# sudo curl https://gist.githubusercontent.com/timonweb/b70467935c6f666cacab67ea4bdea61b/raw/d6e32a5b5a8ddca2d78e2fb55af8a0b6320b9835/tasks.sh -o /usr/local/bin/tasks && sudo chmod +x /usr/local/bin/tasks
tasksfile_path=0
while [[ "`pwd`" != '/' ]]; do
tasksfile_path=$(find $(pwd) -type f -name "Tasksfile" -print | head -n 1)
if [[ -n $tasksfile_path ]]; then
echo "Running 'tasks $@' command:"
#!/bin/bash
# James Shubin, 2018
# run `make` in the first directory (or its parent recursively) that it works in
# https://purpleidea.com/blog/2018/03/10/running-make-from-anywhere/
MF='Makefile' # looks for this file, could look for others, but that's silly
CWD=$(pwd) # starting here
while true; do
if [ -e "$MF" ]; then
const fs = require("fs");
const pathClient = "./node_modules/react-dev-utils/webpackHotDevClient.js";
fs.writeFileSync(
pathClient,
fs
.readFileSync(pathClient)
.toString()
.replace(
@timonweb
timonweb / swiper-magnific-popup.js
Created September 27, 2018 12:01 — forked from thiagoeliasr/swiper-magnific-popup.js
Adding swipe support to Magnific Popup galleries. (touchSwipe is required: http://labs.rampinteractive.co.uk/touchSwipe/demos/)
(function() {
/* Define a variável que dá swipe no lightbox */
var magnificPopup = $.magnificPopup.instance;
/* Carrega a função quando clica no lightbox (senão não pega a classe utilizada) */
$("a.image-lightbox").click(function(e) {
/* Espera carregar o lightbox */
setTimeout(function() {
/* Swipe para a esquerda - Próximo */
@timonweb
timonweb / inline_panel.js
Created August 21, 2018 10:52 — forked from unexceptable/inline_panel.js
OneToOne Wagtail InlinePanel
// stuff/templates/wagtailadmin/edit_handlers/inline_panel.js
(function() {
var opts = {
formsetPrefix: "id_{{ self.formset.prefix }}",
emptyChildFormPrefix: "{{ self.empty_child.form.prefix }}",
canOrder: {% if can_order %}true{% else %}false{% endif %},
maxForms: {{ self.formset.max_num }}
};
var panel = InlinePanel(opts);
@timonweb
timonweb / final_models.py
Last active March 9, 2018 16:14 — forked from lb-/final_models.py
Django + Wagtail - custom taxonomy model. Code for tutorial here: https://posts-by.lb.ee/building-a-configurable-taxonomy-in-wagtail-django-94ca1080fb28
"""Node model and Node admin interaction."""
from django import forms
from django.conf.urls import url
from django.contrib.admin.utils import quote, unquote
from django.core.exceptions import PermissionDenied
from django.core.validators import MinLengthValidator, RegexValidator
from django.db import models
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
@timonweb
timonweb / basic-webpack-config.js
Created May 23, 2017 07:48
A basic ES2015 Webpack Configuration with Uglification
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
entry: './src/main.js',
output: {
path: './dist/',
filename: 'bundle.js'
},
module: {
@timonweb
timonweb / gist:9459beedd98604d05e000cb129b75ef9
Created January 20, 2017 14:44
Add attributes to form fields
from contact_form.forms import ContactForm
# My form is a child of ContactForm class provided by django_contact_form module
class MyContactForm(ContactForm):
def __init__(self, data=None, files=None, request=None,
recipient_list=None, *args, **kwargs):
super().__init__(data=data, files=files, request=request, recipient_list=recipient_list,
*args, **kwargs)
self.fields['name'].widget.attrs['placeholder'] = 'name'
@timonweb
timonweb / headless-chromium-mac.md
Created November 26, 2016 19:49 — forked from corysimmons/headless-chromium-mac.md
Instructions for how to build Headless Chromium on Mac.

Doesn't work yet.

Build

  • brew install ninja
  • mkdir -p ~/chromium
  • cd ~/chromium
  • git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
  • export $PATH=$PWD/depot_tools:$PATH (shell specific)
  • fetch --no-history chromium --nosvn=True
@timonweb
timonweb / __INDEX.txt
Created July 6, 2016 13:05 — forked from facine/__INDEX.txt
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes: