Skip to content

Instantly share code, notes, and snippets.

View endvvell's full-sized avatar
🫀

Ivan endvvell

🫀
  • Kyiv, Ukraine
  • 22:39 (UTC +03:00)
View GitHub Profile
@borkdude
borkdude / test_args.clj
Created November 8, 2022 12:15
Clojure deftest with arguments
;; {:deps {org.babashka/cli {:mvn/version "0.5.40"}
;; babashka/fs {:mvn/version "0.1.11"}}}
(ns test-args
{:clj-kondo/config '{:lint-as {test-args/deftest clojure.core/defn}}}
(:require
[babashka.cli :as cli]
[clojure.test :as t :refer [is]]))
(def ^:dynamic *test-args* (cli/parse-opts *command-line-args*))
@AndreasDickow
AndreasDickow / views.py
Last active May 12, 2024 17:25
Fix object has no attribute 'object_list' when post create duplicate in Django-Tables2 ListView
class mylist(SingleTableMixin, FilterView):
...
def get_context_data(self, **kwargs):
queryset = kwargs.pop('object_list', None)
if queryset is None:
self.object_list = self.model.objects.all()
...
return super().get_context_data(**kwargs)
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active May 21, 2024 14:08
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@illiichi
illiichi / project.clj
Last active December 22, 2023 22:33
pseudoethnological clojure code in 30 lines
(defproject pseudoethnological "0.1.0-SNAPSHOT"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:jvm-opts ["-Xmx2g" "-server"]
:dependencies [[org.clojure/clojure "1.8.0"]
[overtone "0.10.3"]])
@thismatters
thismatters / 0001_migrate_to_encrypted.py
Last active March 5, 2024 00:07
Migrating existing columns to use django-cryptography
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django_cryptography.fields import encrypt
app_with_model = 'account'
model_with_column = 'User'
column_to_encrypt = 'email_address'
column_field_class = models.CharField
@zelark
zelark / pg_test.types.clj
Last active February 2, 2024 19:47
Support json and jsonb Postgres types in Clojure.
;; For supporting more PG types, see https://github.com/remodoy/clj-postgresql
(ns pg-test.types
(:require [cheshire.core :as json]
[clojure.java.jdbc :as jdbc])
(:import [org.postgresql.util PGobject]
[java.sql PreparedStatement]))
;; Writing
(defn- to-pg-json [data json-type]
@duhaime
duhaime / index.html
Last active April 20, 2023 10:00
Three.js: Indexed Buffer Geometry with Texture and Custom Shader Attributes
<html>
<head>
<style>
html, body { width: 100%; height: 100%; background: #000; }
body { margin: 0; overflow: hidden; }
canvas { width: 100%; height: 100%; }
</style>
</head>
<body>
<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/92/three.min.js'></script>
@xirixiz
xirixiz / Set up GitHub push with SSH keys.md
Last active May 18, 2024 17:58 — forked from developius/README.md
Set up GitHub push with SSH keys

SSH keypair setup for GitHub (or GitHub/GitLab/BitBucket, etc, etc)

Create a repo.

Make sure there is at least one file in it (even just the README.md)

Generate a SSH key pair (private/public):

ssh-keygen -t rsa -C "your_email@example.com"
@finalfantasia
finalfantasia / cons_and_lazy_sequences_in_clojure.md
Last active November 7, 2022 16:54
Cons and Lazy Sequences in Clojure

(conj collection item) adds item to collection. To do that, it needs to realize collection. (I'll explain why below.) So the recursive call happens immediately, rather than being deferred.

(cons item collection) creates a sequence which begins with item, followed by everything in collection. Significantly, it doesn't need to realize collection. So the recursive call will be deferred (because of using lazy-seq) until somebody tries to get the tail of the resulting sequence.

The following is how it works internally:

cons actually returns a clojure.lang.Cons object, which is what lazy sequences are made of. conj returns the same type of collection which you pass it (whether that is a list, vector, or whatever else). conj does this using a polymorphic Java method call on the collection itself. (See line 524 of clojure/src/jvm/clojure/lang/RT.java.)

What happens w

@alopresto
alopresto / gpg_git_signing.md
Last active January 18, 2024 22:42
Steps to enable GPG signing of git commits.

If anyone is interested in setting up their system to automatically (or manually) sign their git commits with their GPG key, here are the steps:

  1. Generate and add your key to GitHub
  2. $ git config --global commit.gpgsign true ([OPTIONAL] every commit will now be signed)
  3. $ git config --global user.signingkey ABCDEF01 (where ABCDEF01 is the fingerprint of the key to use)
  4. $ git config --global alias.logs "log --show-signature" (now available as $ git logs)
  5. $ git config --global alias.cis "commit -S" (optional if global signing is false)
  6. $ echo "Some content" >> example.txt
  7. $ git add example.txt
  8. $ git cis -m "This commit is signed by a GPG key." (regular commit will work if global signing is enabled)