This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "static void main" must be defined in a public class. | |
public class Knapsack { | |
private String[] name; | |
private int[] weight; | |
private int[] value; | |
private int[][] m; | |
private int capacity; | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "static void main" must be defined in a public class. | |
public class Main { | |
public static void main(String[] args) { | |
listItem(new String[] {"A","B","C","D","E","F"}); | |
} | |
static public void listItem(String[] names) { | |
int n = names.length; | |
for (int c=0;c<Math.pow(2,n);c++) { | |
System.out.print("{"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.charset.StandardCharsets; | |
import org.eclipse.paho.mqttv5.client.MqttClientPersistence; | |
import org.eclipse.paho.mqttv5.client.persist.MemoryPersistence; | |
import org.eclipse.paho.mqttv5.client.MqttAsyncClient; | |
import org.eclipse.paho.mqttv5.client.MqttConnectionOptions; | |
import org.eclipse.paho.mqttv5.client.IMqttToken; | |
import org.eclipse.paho.mqttv5.common.MqttSubscription; | |
import org.eclipse.paho.mqttv5.client.MqttCallback; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StatusBar } from 'expo-status-bar'; | |
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
// expo install mqtt | |
// fix refer to mqtt.js issue: https://github.com/mqttjs/MQTT.js/issues/573 | |
const mqtt = require('mqtt/dist/mqtt') | |
export default function App() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspect the Root CA Cert of your domain, and it as ca.crt | |
openssl s_client -connect <host>:<port> -showcerts | |
# Verify the cert contexnt | |
openssl x509 -in ca.crt -text | |
# Create the Java Keystore file (JKS) and import the ca.crt into it | |
jdk/bin/keytool -import -file ca.crt -keystore trust.jks -storepass password | |
# Verify the JKS file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bkupdir="<your backup folder>/bkup_`date +%Y%m%d_%H%M%S`" | |
log="$bkupdir/backup.log" | |
mkdir -p $bkupdir | |
echo "backup folder : $bkupdir" | |
echo "Start time : `date`" >> $log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bkupdir="bkup_`date +%Y%m%d_%H%M%S`" | |
restorefile="$bkupdir/restore.sh" | |
log="$bkupdir/backup.log" | |
mkdir $bkupdir | |
echo "#!/bin/bash" > $restorefile | |
chmod u+x $restorefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker login -u <<registry login>> -p <<password>> <<user registry host>> | |
docker ps -a --format "{{.ID}} {{.Image}}" | grep <<your registry prefix>> | \ | |
while read line | |
do | |
ctrid=`echo $line | awk '{print $1}'` | |
imgtag=`echo $line | awk '{print $2}'` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import ReactDOM from 'react-dom'; | |
import * as serviceWorker from './serviceWorker'; | |
import { createStore, combineReducers, applyMiddleware } from 'redux'; | |
import { Provider, useSelector, useDispatch } from 'react-redux'; | |
import { Card } from 'react-bootstrap'; | |
import 'bootstrap/dist/css/bootstrap.min.css'; | |
import thunk from 'redux-thunk'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import * as serviceWorker from './serviceWorker'; | |
import { createStore, combineReducers } from 'redux'; | |
import { Provider, useSelector, useDispatch } from 'react-redux'; | |
const reducer = combineReducers({ | |
counter: (state = 0, action) => { | |
switch (action.type) { | |
case "INCR": |
NewerOlder