Skip to content

Instantly share code, notes, and snippets.

@thomasnield
thomasnield / calling_kotlin_from_python.py
Created June 2, 2018 23:09
Calling Kotlin from Python
os.system("kotlinc src/main/kotlin/Launcher.kt -include-runtime -d launcher.jar")
process = Popen(['java', '-jar', 'launcher.jar', tmp_file_name], stdout=PIPE)
(stdout, stderr) = process.communicate()
@namhyun-gu
namhyun-gu / extract_font_url.js
Last active April 20, 2024 10:27
Extract font url from css (in javascript)
const regex = /url\((.*?)\) format\((\'|\")(.*?)(\'|\")\)/g;
const str = `CSS Input`;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
@AlexVipond
AlexVipond / README.md
Last active April 20, 2024 10:23
Updating arrays of elements with function refs in Vue 3

Updating arrays of elements with function refs in Vue 3

I did a screencast series recently talking about my favorite Vue 3 feature: function refs. Check out the screencast series for more context-in this gist, I'm going to answer a fantastic question I got in one of the videos' comment section.

This question was about how to properly update arrays of elements that are captured by function refs. Let's check out the basic principle first, before we look at the details of the question.

<script setup>
import { ref, onBeforeUpdate } from 'vue'
@jtmoon79
jtmoon79 / python-embedded-for-Win10.md
Last active April 20, 2024 10:23
fully configuring embedded Python on Windows 10

Update: use PowerShell script PythonEmbed4Win.ps1.

The instructions in this gist have some subtle problems and this gist will not be updated.

About


@fearrr
fearrr / phone_regexp.md
Last active April 20, 2024 10:21
Регулярное выражение для мобильных и городских номеров России и СНГ

Регулярное выражение для мобильных и городских номеров России и СНГ

Страны:

  • Армения (+374),
  • Азербайджан (+994)
  • Грузия (+995)
  • Беларусь (+375)
  • Россия/Казахстан (+7)
  • Украина (+380, +38)
@straker
straker / README.md
Last active April 20, 2024 10:20
Basic Snake HTML and JavaScript Game

Basic Snake HTML and JavaScript Game

Snake is a fun game to make as it doesn't require a lot of code (less than 100 lines with all comments removed). This is a basic implementation of the snake game, but it's missing a few things intentionally and they're left as further exploration for the reader.

Further Exploration

  • Score
  • When the snake eats an apple, the score should increase by one. Use context.fillText() to display the score to the screen
@JonathanMaes
JonathanMaes / terminator.py
Last active April 20, 2024 10:17
Terminator boundary calculator (and plotting)
""" This script implements a class for calculating the Earth terminator.
Additional functionality for calculating the boundary of the various
twilight types and plotting these areas on a 2D map are also provided.
--------------------------------------------------------------------------
Copyright (C) 2023 Jonathan Maes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@arkatsy
arkatsy / zustand-internals.jsx
Last active April 20, 2024 10:15
How zustand works internally
import { useSyncExternalStore } from "react";
// For more on the useSyncExternalStore hook, see https://react.dev/reference/react/useSyncExternalStore
// The code is almost identical to the source code of zustand, without types and some features stripped out.
// Check the links to see the references in the source code.
// The links are referencing the v5 of the library. If you plan on reading the source code yourself v5 is the best way to start.
// The current v4 version contains lot of deprecated code and extra stuff that makes it hard to reason about if you're new to this.
// https://github.com/pmndrs/zustand/blob/fe47d3e6c6671dbfb9856fda52cb5a3a855d97a6/src/vanilla.ts#L57-L94
function createStore(createState) {
@denji
denji / nginx-tuning.md
Last active April 20, 2024 10:12
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@santansarah
santansarah / uninstall-google-play-services.md
Last active April 20, 2024 10:06
Uninstall/Reinstall Google Play Services

When we're working with Google Play Service APIs, we might run into various development issues. This recently happened to me while using com.google.android.gms:play-services-code-scanner. I've also run into issues with Google Sign In. Sometimes, the only thing left to do is to uninstall Google Play Services, and start fresh.

Uninstalling Google Play Services can also be useful if you'd like to test your app out as a brand new user, with none of your app settings saved to Google Play Services.

WARNING: This will delete settings, etc. Proceed at your own caution.

  1. Open https://play.google.com/store/apps/details?id=com.google.android.gms from your Android device.
  2. From the Play Store, click Uninstall.
  3. For the prompt, click Uninstall again.
  4. Click Update.