Skip to content

Instantly share code, notes, and snippets.

View TerryFunggg's full-sized avatar
🛌
writing dummy code

Terry Funggg TerryFunggg

🛌
writing dummy code
View GitHub Profile
(use-package polymode
:ensure t
:defer t
:hook (vue-mode . lsp-deferred)
:mode ("\\.vue\\'" . vue-mode)
:config
(define-innermode poly-vue-template-innermode
:mode 'html-mode
:head-matcher "^<[[:space:]]*\\(?:template\\)[[:space:]]*>"
:tail-matcher "^</[[:space:]]*\\(?:template\\)[[:space:]]*>"
class Workout < ApplicationRecord
belongs_to :sport
scope :most_recent_by_sport, -> do
from(
<<~SQL
(
SELECT workouts.*
FROM workouts JOIN (
SELECT sport_id, max(created_at) AS created_at
@cschiewek
cschiewek / x11_docker_mac.md
Last active November 6, 2024 12:03
X11 in docker on macOS

To forward X11 from inside a docker container to a host running macOS

  1. Install XQuartz: https://www.xquartz.org/
  2. Launch XQuartz. Under the XQuartz menu, select Preferences
  3. Go to the security tab and ensure "Allow connections from network clients" is checked.
  4. Run xhost + ${hostname} to allow connections to the macOS host *
  5. Setup a HOSTNAME env var export HOSTNAME=`hostname`*
  6. Add the following to your docker-compose:
 environment:
@joepie91
joepie91 / express-server-side-rendering.md
Last active July 26, 2024 09:56
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
@belak
belak / .gitignore
Last active July 6, 2022 19:26
Simple Emacs Starter Kit
README.el
backups/
elpa/
projectile-bookmarks.eld
recentf
smex-items
@ichadhr
ichadhr / jekyll-post-thor.md
Last active February 8, 2024 10:27
Jekyll create post with command

CREATE JEKYLL POSTS FROM THE COMMAND LINE

I got tired on creating new files manually for each new post a write so I put together this little command line task with Thor.

It creates a new file in the _posts directory with today’s date, parses the parameters to command as the post’s title and adds that as a slug to the new file. It then writes a default yaml template to the file (as specified in the script).

Running thor jekyll:new New and shiny post will for example create the file _posts/2012-12-28-new-and-shiny-post.markdown, populate it with an yaml template and finally open the file in my favorite editor.

HOW TO

Add the following to your Gemfile:

@yurydelendik
yurydelendik / gist:f2b846dae7cb29c86d23
Last active October 1, 2024 08:02
PDF.js get/show hightlight
function getHightlightCoords() {
var pageIndex = PDFViewerApplication.pdfViewer.currentPageNumber - 1;
var page = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
var pageRect = page.canvas.getClientRects()[0];
var selectionRects = window.getSelection().getRangeAt(0).getClientRects();
var viewport = page.viewport;
var selected = selectionRects.map(function (r) {
return viewport.convertToPdfPoint(r.left - pageRect.x, r.top - pageRect.y).concat(
viewport.convertToPdfPoint(r.right - pageRect.x, r.bottom - pageRect.y));
});
@meandmax
meandmax / single-and-fat-arrow-functions.md
Last active February 2, 2021 08:09
Don’t use fat arrows in CoffeeScript just because of »this«

New Coffeescript programmers usually struggle with understanding the differences between -> and => function definitions. In order to clarify this common case of confusion, it helps to look at how such functions are compiled down to JavaScript.

class A

    constructor: () ->
        @funcA()
        @funcB()

 funcA: () -&gt;