Skip to content

Instantly share code, notes, and snippets.

View hvitis's full-sized avatar
👨‍🔬
Never trust atoms; they make up everything.

Adam Piskorek hvitis

👨‍🔬
Never trust atoms; they make up everything.
View GitHub Profile
@hvitis
hvitis / javascript_tips_01.js
Created January 11, 2022 10:08
🔥 JavaScript Syntactic Sugar 🍭
// Nullish coalescing operator with conditional chaining
let alien = {
isAware: true,
location : {
planet: "C435",
distance: 30 // light years
}
};
const alienGreeting = alien?.name ?? "Welcome Stranger!";
@hvitis
hvitis / mixins.py
Created January 11, 2022 00:03 — forked from vst/mixins.py
Some Django model mixins
# Copyright (c) 2012, Vehbi Sinan Tunalioglu <vst@vsthost.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
@hvitis
hvitis / redis-autostart-osx.md
Created November 5, 2021 09:38 — forked from subfuzion/redis-autostart-osx.md
redis auto start OS X

Install with Homebrew

brew install redis

Set up launchctl to auto start redis

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)

@hvitis
hvitis / imagewiththumbnails_updateable.py
Created February 13, 2021 02:36 — forked from valberg/imagewiththumbnails_updateable.py
Django create thumbnail form ImageField and save in a different ImageField - now with updating!
# Extension of http://www.yilmazhuseyin.com/blog/dev/create-thumbnails-imagefield-django/
# Note: image_folder and thumbnail_folder are both a callable (ie. a lambda that does a '/'.join())
class Image(Media):
image = models.ImageField(
upload_to=image_folder
)
thumbnail = models.ImageField(
@hvitis
hvitis / Count lines in Git repo
Created January 30, 2021 21:08 — forked from mandiwise/Count lines in Git repo
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@hvitis
hvitis / load_dotenv.sh
Created January 28, 2021 19:32 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@hvitis
hvitis / load_dotenv.sh
Created January 28, 2021 19:32 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@hvitis
hvitis / load_dotenv.sh
Created January 28, 2021 19:32 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@hvitis
hvitis / PaperJS with GatsbyJS to use Raster mosaic functionality.
Last active October 6, 2021 13:01
PaperJS with GatsbyJS to use Raster mosaic functionality.
import React from "react"
import { Form, Container, Row, Col, Badge } from "react-bootstrap"
import colors from "./utils/colors.json"
import BadgeColor from "./utils/BadgeColor.tsx"
import { IoIosCheckmarkCircle, IoIosCheckbox } from "react-icons/io"
import { formatAndDownloadBsxFile } from "./utils/formatBsxFile"
import { formatAndDownloadXmlFile } from "./utils/formatXmlFile"
import { formatAndDownloadLdrFile } from "./utils/formatLDrawFile"
class PaperCanvas extends React.Component {
constructor(props) {
@hvitis
hvitis / gist:65d928dc1a68126b8098e2d52ff66154
Created October 18, 2020 16:24
DRF Filepond implementation
```js
<file-pond
name="filepond"
ref="pond"
label-idle="Drop file here..."
v-bind:allow-multiple="false"
accepted-file-types="image/jpeg, image/png, image/jpg"
v-bind:files="myFiles"
v-on:init="handleFilePondInit" <-- Example optional hook
v-on:processfile="handleFilePondSuccessProcessed" <-- Example optional hook