Skip to content

Instantly share code, notes, and snippets.

View salex89's full-sized avatar

Aleksandar Stojadinovic salex89

View GitHub Profile
@salex89
salex89 / asus_ssh.sh
Created May 30, 2020 00:03
Enable/disable WiFi over SSH RT-AC66U B1
# 2.4GHz
nvram set wl0_radio=0 # 0 to disable, or 1 to enable
# 5GHz
nvram set wl1_radio=0 # 0 to disable, or 1 to enable
nvram commit
service restart_wireless
@salex89
salex89 / .gitconfig
Last active May 24, 2017 09:40
Example gitconfig file. Sets up Meld on Windows for merging and diff, enables rerere and skips creating .orig files.
[user]
email = <email>
name = Aleksandar Stojadinovic
[merge]
tool = meld
[mergetool]
keepBackup = false
[mergetool "meld"]
trustExitCode = true
path = C:\\Program Files (x86)\\Meld\\Meld.exe
@salex89
salex89 / sprint-test-example.java
Last active December 14, 2016 21:01
Spring test 1.4 example
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT/*, classes = Application.class*/)
//@DataJpaTest //Starts with in-memory database, without a web tier, only data tier
//@RestClientTest({RemoteVehicleDetailsService.class}) //Use with REST client class
//@TestPropertySource(properties = "vehicle.service.root-url=http://example.com")
//@JsonTest //Testing JSON (de)serialization
//@AutoConfigureTestDatabase //self-explanatory
//@WebMvcTest(UserVehicleController.class) //MVC class
public class ApplicationIntegrationTest {
@salex89
salex89 / application.yml
Last active March 3, 2023 08:23
Spring application.yml useful snippets
spring:
datasource:
url: jdbc:h2:./repository/db;MV_STORE=FALSE # MV_STORE=FALSE to use the old 1.3 format
driver-class-name: org.h2.Driver
username: sa
# password: sa
jpa:
hibernate.ddl-auto: validate
# Lines dedicated only to generating the script file, it is not applied to the DB. These are from JPA, not from Hibernate
properties.javax.persistence.schema-generation.create-source: metadata
@salex89
salex89 / dropbox-icon-fix.sh
Created October 27, 2016 13:03
A patch for the Dropbox notification area icon bug for Xubuntu 16.04. Curtesy of: http://www.webupd8.org/2016/06/fix-dropbox-indicator-icon-and-menu-not.html
cp ~/.config/autostart/dropbox.desktop ~/.config/autostart/start_dropbox.desktop
sed -i 's/^Exec=.*/Exec=dbus-launch dropbox start -i/' ~/.config/autostart/start_dropbox.desktop
dropbox autostart n
mkdir -p ~/.local/share/applications/
cp /usr/share/applications/dropbox.desktop ~/.local/share/applications/
sed -i 's/^Exec=.*/Exec=dbus-launch dropbox start -i/' ~/.local/share/applications/dropbox.desktop
@salex89
salex89 / docker-private-registries
Created October 13, 2016 12:35
List of private docker repositories (self-hosted and SaaS) other than Docker Hub
Portus - http://port.us.org/
Quay - https://quay.io/
Harbor - https://vmware.github.io/harbor/
Atomic Registry - http://www.projectatomic.io/registry/
Nexus Repository Manager OSS 3.xx - https://www.sonatype.com/nexus-repository-oss
"Official" Docker Registry 2.0 - https://docs.docker.com/registry/
@salex89
salex89 / hibernate-authenticator-dropwizard.java
Created October 10, 2016 19:56
Hibernate session in Dropwizard authenticator.
GrowwAuthenticator authenticator = new UnitOfWorkAwareProxyFactory(hibernateBundle)
.create(GrowwAuthenticator.class, SessionFactory.class,
hibernateBundle.getSessionFactory());
@salex89
salex89 / RetryWithCountdownPoller.java
Last active September 12, 2016 15:24
The poller executes an operation a predetermined number of times with pauses between each execution. Success of the operation is determined using a supplied predicate. Three callbacks exist: onSuccess, onFailure and onFinish (which is called in any case). onFailure and onFinish can handle based on the last obtained value (if any) sent to the pre…
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
/**
* Created by Aleksandar Stojadinovic on 12/09/16.
*/
@salex89
salex89 / postgres_delete_all.sql
Created September 7, 2016 13:58
Stored procedure, drop all entries in all tables in Postgres without dropping or truncating, with optional ignoring.
DECLARE
statements CURSOR FOR
SELECT tablename FROM pg_tables
WHERE tableowner = username AND schemaname = 'public';
BEGIN
FOR stmt IN statements LOOP
IF stmt.tablename != 'algorithm' THEN
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
END IF;
END LOOP;
@salex89
salex89 / rancher-upgrade-example
Created August 31, 2016 08:34
Rancher compose call for pulling and upgrading a stack
rancher-compose --url <rancher_compose_url> --access-key <key> --secret-key <secret_ky> -f docker-compose.yaml -p <stack_name> up --pull --force-upgrade --confirm-upgrade -d