Skip to content

Instantly share code, notes, and snippets.

@superseb
superseb / restore_rancher2_agents.md
Last active November 14, 2024 10:09
Restore Rancher 2 cluster/node agents on clusters

Restore Rancher 2 cluster/node agents on clusters

This is an unsupported scenario, see rancher/rancher#14731 when there is an official solution.

When cattle-cluster-agent and/or cattle-node-agent are accidentally deleted, or when server-url/cacerts are changed.

Generate definitions

  • Generate API token in the UI (user -> API & Keys) and save the Bearer token
  • Find the clusterid in the Rancher UI (format is c-xxxxx), its in the address bar when the cluster is selected
@H-Max
H-Max / mongodb-backup.sh
Last active September 11, 2024 16:11
Backup mongodb database directly to S3
# Use environment variable as password (could also be a password stored in a file, read with cat)
# DO NOT use --password argument in mongodump command or authentication will fail
# DO NOT add a file name after --archive argument, or mongodump output won't be sent to stdout
# Use S3 infrequent access storage class to reduce cost
# Use aes-256 encryption of your file on S3 (or your own KMS keys)
# Benefits of this method :
# 1 > You won't see the password sent to mongodump using in ps command (it's safe in a multi-user environment)
# 2 > You don't have to store the backup locally before sending it to S3
# 3 > Everything is done in one line, fits a cronjob easily
@brennanMKE
brennanMKE / hero.ts
Last active March 19, 2026 17:42
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;
@SqlResultSetMapping(
name = "AuthorValueMapping",
classes = @ConstructorResult(
targetClass = AuthorValue.class,
columns = {
@ColumnResult(name = "id", type = Long.class),
@ColumnResult(name = "firstname"),
@ColumnResult(name = "lastname"),
@ColumnResult(name = "numBooks", type = Long.class)}))
@leolin310148
leolin310148 / spring_security_oauth2_mysql.schema
Last active August 25, 2020 02:29
Spring Security OAuth2 MySQL Schema
create table oauth_client_details (
client_id VARCHAR(255) PRIMARY KEY,
resource_ids VARCHAR(255),
client_secret VARCHAR(255),
scope VARCHAR(255),
authorized_grant_types VARCHAR(255),
web_server_redirect_uri VARCHAR(255),
authorities VARCHAR(255),
access_token_validity INTEGER,
refresh_token_validity INTEGER,
@waja
waja / openwrt_x86.install
Last active August 10, 2018 12:06
Openwrt x86 installation
# look also at
# http://wiki.openwrt.org/doc/recipes/relayclient
# http://wiki.openwrt.org/doc/recipes/dumbap
# disable dhcp on lan interface (just in case there is a dhcp server running)
uci set dhcp.lan.ignore=1
uci set dhcp.@dnsmasq[0].nonegcache=1
uci commit dhcp
/etc/init.d/dnsmasq restart
@Vp3n
Vp3n / gist:5340891
Created April 8, 2013 21:55
Allowing CORS (Cross-Origin Resource Sharing) requests from grunt server
//Allowing CORS (Cross-Origin Resource Sharing) requests from
// grunt server, put this into Gruntfile.js
grunt.initConfig({
connect: {
livereload: {
options: {
port: 9000,
hostname: 'localhost',
middleware: function (connect) {
return [
anonymous
anonymous / cronjob
Created December 19, 2012 14:32
bootstraps the framework and would allow you to create your app however you want
#!/usr/bin/php
<?php
/**
* @version $Id$
* @package Joomla.Example
* @subpackage CLI
* @copyright Copyright (C) 2008 - 2009 Louis Landry. All rights reserved.
* @license GNU General Public License, <http://www.gnu.org/copyleft/gpl.html>
*/
@mkuklis
mkuklis / gist:3813128
Created October 1, 2012 17:17
zepto click and tap events for mobile & desktop
if ('ontouchstart' in window) {
// turn off click event
$(document)
.on('click', 'a', function(e) {
e.preventDefault();
e.stopPropagation();
})
.on('tap', 'a', function(e) {
window.location.href = $(e.currentTarget).attr('href');
});
@axelpale
axelpale / combinations.js
Last active October 11, 2025 20:04
JavaScript functions to calculate combinations of elements in Array.
/**
* Copyright 2012 Akseli Palén.
* Created 2012-07-15.
* Licensed under the MIT license.
*
* <license>
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,