Skip to content

Instantly share code, notes, and snippets.

@adamjohnson
adamjohnson / publickey-git-error.markdown
Last active May 10, 2024 09:59
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
@Rahandi
Rahandi / config.php
Created May 1, 2018 10:51
pendaftaran-siswa
<?php
$server = "localhost";
$user = "root";
$password = "";
$nama_database = "pendaftaran_siswa";
$db = mysqli_connect($server, $user, $password, $nama_database);
if( !$db ){
die("Gagal terhubung dengan database: " . mysqli_connect_error());
@akwodkiewicz
akwodkiewicz / resolver.js
Created May 10, 2024 08:59
Custom Jest resolver to solve "dual state" issues with self-referencing and subpath imports in TypeScript projects
/**
* This resolver forces Jest to look at a *custom* `"jest"` condition in `package.json#exports`.
*
* Whenever you use self-referencing imports or subpath imports in the source code (or tests)
* the default behaviour of Jest is to go to the package's manifest for information, and resolve
* the import by choosing one of the conditions that are used by Node ("node", "default", etc.).
*
* The issue is that "node"/"default" usually points to transpiled `.js` files, whereas if you decide to
* run the tests on the `.ts` source code (with the help of a transformer such as ts-jest or @swc/jest),
* you need Jest to **only** load the `.ts` files. Otherwise, you end up with duplicated classes,
@pmenke-de
pmenke-de / README.md
Last active May 10, 2024 09:54 — forked from chpatrick/nix-cmake
Using CLion with Nix

let's say you have a C++ project in Nix that you want to work on with CLion so that the nix dependencies are available.

  1. create a .nix utility directory in your project directory.
  2. put the below nix-run.sh and nix-cmake.sh in the .nix directory.
  3. in the .nix directory create symlinks for make, gcc, g++ - and maybe more tools, that need to have the nix dependencies and build tools available - and point them to nix-run.sh
  4. then, in Settings -> Build, Execution, Deployment -> Toolchains set CMake to the path to nix-cmake.sh and point all other build tools to the symlinks you've created.
@MarkWarneke
MarkWarneke / Makefile
Created June 18, 2020 12:25
Makefile for python code
# Makefile for python code
#
# > make help
#
# The following commands can be used.
#
# init: sets up environment and installs requirements
# install: Installs development requirments
# format: Formats the code with autopep8
# lint: Runs flake8 on src, exit if critical rules are broken
@Strus
Strus / clangd.md
Last active May 10, 2024 09:49
How to use clangd C/C++ LSP in any project

How to use clangd C/C++ LSP in any project

tl;dr: If you want to just know the method, skip to How to section

Clangd is a state-of-the-art C/C++ LSP that can be used in every popular text editors like Neovim, Emacs or VS Code. Even CLion uses clangd under the hood. Unfortunately, clangd requires compile_commands.json to work, and the only way to painlessly generate it is to use CMake.

But what if I tell you you can quickly hack your way around that, and generate compile_commands.json for any project, no matter how compilcated? I have used that way at work for years, originaly because I used CLion which supported only CMake projects - but now I use that method succesfully with clangd and Neovim.

Method summary

Basically what we need to achieve is to create a CMake file that will generate a compile_commands.json file with information about:

@sebkln
sebkln / RequestMiddlewares.php
Created January 6, 2024 15:48
Middleware for web manifest in TYPO3 v12. Adjusted version of the solution provided by Kevin Appelt in TYPO3 Slack: https://typo3.slack.com/archives/C025BQLFA/p1680299950579649
<?php
return [
'frontend' => [
'yourvendor/webmanifest' => [
'target' => \YourVendor\Sitepackage\Middleware\Webmanifest::class,
'before' => [
'typo3/cms-frontend/page-resolver',
],
'after' => [
@qgy18
qgy18 / index.js
Created March 23, 2024 05:15
update certificate to tencent cdn
const fs = require('fs');
const tencentcloud = require('tencentcloud-sdk-nodejs');
const TENCENTCLOUD_SECRET_ID = 'your secret id';
const TENCENTCLOUD_SECRET_KEY = 'your secret key';
const CERTIFICATE_PUBLIC_KEY_FILE = 'your public cert file';
const CERTIFICATE_PRIVATE_KEY_FILE = 'your private cert file';
const CERTIFICATE_DOMAIN = 'your domain';
@ekollof
ekollof / sshfp.yml
Created January 30, 2020 12:40
ansible playbook getting/registering sshfp records with cloudflare
- name: get SSHFP records
shell: "ssh-keygen -r {{ ansible_nodename }} | awk '{print $4, $5, $6}'"
register: sshfp_entries
- name: Register SSHFP with CloudFlare
cloudflare_dns:
zone: "hackerheaven.org"
record: "{{ ansible_hostname }}"
type: SSHFP
account_email: "{{ cloudflare_email }}"
@odudex
odudex / nostr_seed.py
Last active May 10, 2024 09:43
Uses Embit to convert hex or bech32 keys to BIP39 seed words and vice-versa
"""Uses Embit and qrcode modules to convert hex and bech32 keys to BIP39 seed words and vice-versa.
Also generates ascii compact seed QR codes.
Install Embit:
pip install embit
Exemple: Words as input:
python nostr_c_seed_qr.py picture body actor coil end satoshi fish mom distance proof thank play fantasy friend dinner clump boring ozone review cart virtual toss foot infant
Hex Key: a4431c0a96a4997ed5ec763fb58b7f532530b9cf916219f3d2e2118f47cb56bb
Bech32 key: nsec153p3cz5k5jvha40vwclmtzml2vjnpww0j93pnu7juggc737t26ascxcmgr
BIP39 seed numbers: [1315, 200, 22, 363, 589, 1532, 702, 1143, 510, 1379, 1791, 1331, 665, 744, 499, 355, 208, 1269, 1477, 281, 1956, 1838, 728, 923]