Skip to content

Instantly share code, notes, and snippets.

View svict4's full-sized avatar
🏦
shilling crypto

Simon Victory svict4

🏦
shilling crypto
View GitHub Profile
@parmentf
parmentf / GitCommitEmoji.md
Last active May 16, 2024 19:31
Git Commit message Emoji
@randomecho
randomecho / australian-postcodes.sql
Last active May 11, 2024 07:46
Australian postcodes (with states and suburb names) geocoded with latitude and longitude.
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@emanuelez
emanuelez / git_speed.md
Last active March 17, 2024 19:03
Git Speed

How Fast is Git?

The web is full of benchmarks showing the supernatural speed of Git even with very big repositories, but unfortunately they use the wrong variable. Size is not important, but the number of files in the repository really is!

Why is that? Well, that's because Git works in a very different way compared to Synergy. You don't have to checkout a file in order to edit it; Git will do that for you automatically. But at what price?

The price is that for every Git operation that requires to know which files changed (git status, git commmit, etc etc) an lstat() call will be executed for every single file

Wow! So how does that perform on a fairly large repository? Let's find out! For this example I will use an example project, which has 19384 files in 1326 folders.

@Chris820
Chris820 / Vagrantfile
Last active December 19, 2023 06:04
My Vagrantfile. Creates a LAMP environment suitable for Drupal and Wordpress development.
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder "~/Documents/Sites", "/var/www/html", mount_options: ["dmode=777", "fmode=777"]
config.vm.synced_folder "~/vagrant-localdev/db-details", "/var/www/db-details"
config.vm.synced_folder "~/vagrant-localdev/configs", "/etc/apache2/sites-enabled"
config.vm.synced_folder "~/vagrant-localdev/logs", "/var/www/logs"
config.vm.synced_folder "~/vagrant-localdev/scripts", "/home/vagrant/scripts"
config.vm.synced_folder "~/Documents/Transfer", "/home/vagrant/transfer"
# Plenty of memory and CPU cores
@Froelund
Froelund / _error.tsx
Last active November 30, 2023 04:35
Next.js Typescript error reporting
import { captureException, flush } from '@sentry/nextjs';
import NextErrorComponent from 'next/error';
import type { ErrorProps } from 'next/error';
import type { NextPage } from 'next';
interface AppErrorProps extends ErrorProps {
err?: Error;
hasGetInitialPropsRun?: boolean;
}
@raphaellarrinaga
raphaellarrinaga / drupal_8_twig_cheatsheet.md
Last active July 20, 2023 21:21
[Drupal 8 Twig cheatsheet] #tags: drupal8, twig, cheatsheet

Drupal 8 Twig cheatsheet

Please note I created that sheet as a personal side note/draft and not everything is fully tested. There could be errors or better things to do. So if you spot something wrong or something that can be improved, feel free to comment below and I will do the changes.

Getting Drupal 8 field values in Twig

Image path: {{ file_url(content.field_name['#items'].entity.uri.value) }}

using System.Web.Mvc;
using Telerik.Sitefinity.Mvc;
namespace SitefinityWebApp.Mvc.Controllers
{
[ControllerToolboxItem(Name = "FileAsyncUploader", Title = "File Async Uploader", SectionName = "Custom MVC", CssClass = "sfMvcIcn")]
public class FileAsyncUploaderController: Controller
{
[HttpGet]
public ActionResult Index()
@sitefinitySDK
sitefinitySDK / InlineEditingView.cshtml
Created February 24, 2018 22:04
SF_10.1, SF_10.2, SF_11.0, SF_11.1, SF_11.2, SF_12.0, SF_12.1, SF_12.2, SF_13.0, SF_13.1, SF_13.2, SF_13.3, SF_14.0, SF_14.1, SF_14.2, SF_14.3 - https://docs.sitefinity.com/feather-enable-inline-editing-in-widgets
//Enable inline editing:
<li @Html.InlineEditingAttributes(Model.ProviderName, "Telerik.Sitefinity.News.Model.NewsItem", item.Id)>
</li>
//Enable editiong of a particular field:
<a @Html.InlineEditingFieldAttributes("Title", "ShortText") href="…">@item.Title</a>
@milankorsos
milankorsos / redux-actions.ts
Last active November 10, 2022 10:58
Correct TypeScript typing example for Redux Thunk actions
import {Action, ActionCreator, Dispatch} from 'redux';
import {ThunkAction} from 'redux-thunk';
// Redux action
const reduxAction: ActionCreator<Action> = (text: string) => {
return {
type: SET_TEXT,
text
};
};