Skip to content

Instantly share code, notes, and snippets.

@mruv
mruv / postgres-cheatsheet.md
Created July 17, 2019 08:06 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
default_platform(:android)
platform :android do
desc "Clean and Build a Signed APK"
lane :clean_build do
gradle(
task: "clean assembleRelease",
print_command: false,
properties: {
const { Api, JsonRpc, RpcError } = require('eosjs');
const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig');
const fetch = require('node-fetch');
const { TextDecoder, TextEncoder } = require('text-encoding');
const signatureProvider = new JsSignatureProvider(["5JUVf4PgAppQciKbxngmmfWHsmaxGcfKu53X6zpKTK2zg25MsEn"]);
const rpc = new JsonRpc('http://node.dealin.io:1888', { fetch });
const api = new Api({
rpc,
signatureProvider,
const { JsonRpc } = require('eosjs');
const fetch = require('node-fetch');
const rpc = new JsonRpc('http://node.dealin.io:1888', { fetch });
// rewards - By customer
(async () => {
const res = await rpc.get_table_rows({
json: true,
@mruv
mruv / swap_without_temp.cpp
Created March 20, 2019 21:39
Swap 2 numbers without using an extra temporary variable.
void swap_without_temp(int *x, int *y) {
*x = *x + *y;
*y = *x - *y;
*x = *x - *y;
}
import tensorflow as tf
import pandas as pd
from sklearn.model_selection import StratifiedKFold
def tf_cross_val_score(X, y, x_col_nms, n_classes):
"""
Takes features, number of classes, labels and feature vector names and returns 3 validation scores.
*X* Numpy ndarray - features
@Configuration
public class RestTemplateSslConfig {
@Bean("httpsRestTemplate")
@Scope("singleton")
public RestTemplate httpsRestTemplate()
throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import static java.time.format.DateTimeFormatter.ofPattern;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
# data source
spring.datasource.url=jdbc:mysql://localhost:3306/DATABASE_NAME?zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.username=DATABASE_USER
spring.datasource.password=DATABASE_PWD
# ddl && hibernate
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.connection.driver_class=com.mysql.jdbc.Driver
//prints all prime numbers from 1 to 100
class PrimeNumbers{
public static void main(String[] args){
for(int i = 1; i < 100; ++i){//no. to test
boolean isPrime = true;
for(int j = 1; j < 100; ++j){
if(j != 1 && j != i){//don't divide by one or itself