Skip to content

Instantly share code, notes, and snippets.

View gantu's full-sized avatar
🏠
Working from home

Mirlan Ipasov gantu

🏠
Working from home
  • Bishkek/Kyrgyzstan
View GitHub Profile
@gantu
gantu / curl.md
Created May 19, 2021 18:10 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@gantu
gantu / models.java
Created May 19, 2021 17:37 — forked from leefsmp/models.java
Basic RESTful API from a Java servlet
package com.autodesk.adn.viewanddata;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.HashMap;
import java.util.UUID;
import javax.servlet.ServletException;
@gantu
gantu / turn-on-wifi-hot-spot.sh
Created September 15, 2020 10:03 — forked from beginor/turn-on-wifi-hot-spot.sh
Trun on wifi spot by adb.
# open setting
adb shell am start -n com.android.settings/.TetherSettings
# down
adb shell input keyevent 20
# enter
adb shell input keyevent 66
@gantu
gantu / Solution.scala
Created April 17, 2019 14:24
The Inquiring Manager -- Solution with immutable state
package example
import scala.annotation.tailrec
object Solution{
def main(args: Array[String]) = {
val controls = scala.io.StdIn.readInt
mainLoop(OrderSate(Map.empty), controls)
}
def addMouseScroll[A](comboBox: JComboBox[A]): Unit = {
comboBox.addMouseWheelListener(new MouseAdapter {
override def mouseWheelMoved(e: MouseWheelEvent): Unit = {
val itemCount = comboBox.getItemCount
val index = comboBox.getSelectedIndex + e.getWheelRotation
val newIndex = if (index < 0 ) itemCount + index else index % itemCount
comboBox.setSelectedIndex(newIndex)
}
})
@gantu
gantu / Future-retry.scala
Created March 7, 2019 17:39 — forked from viktorklang/Future-retry.scala
Asynchronous retry for Future in Scala
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.
@gantu
gantu / AdbCommands
Created November 10, 2018 17:31 — forked from Pulimet/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
@gantu
gantu / clean-up-boot-partition-ubuntu.md
Created March 2, 2018 11:35 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@gantu
gantu / lxc.sh
Created April 13, 2017 05:37 — forked from reqshark/lxc.sh
set up linux containers with node.js
# update the host
apt-get update && apt-get upgrade -y # && apt-get dist-upgrade -y && apt-get autoremove --purge -y && apt-get autoclean -y
# https://www.stgraber.org/
# install linux containers
sudo apt-get install lxc
# list all containers and view their current status
sudo lxc-ls -f