Skip to content

Instantly share code, notes, and snippets.

View daduskacpokus's full-sized avatar
:octocat:
https://codepen.io/daduskacpokus/pen/RzQbbb?editors=0011#0

Vladislav Tolstykh daduskacpokus

:octocat:
https://codepen.io/daduskacpokus/pen/RzQbbb?editors=0011#0
  • RU
View GitHub Profile
@noqqe
noqqe / bitcoin.sh
Created June 4, 2011 10:32
Bitcoin Mining Script for Debian
#!/bin/bash
### BEGIN INIT INFO
# Provides: BitCoinMining
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: Start/stop BitCoing Mining poclbm-mod
### END INIT INFO
@teffalump
teffalump / README.md
Last active June 16, 2024 18:43
OpenWRT adblock implementation

Others have recently developed packages for this same functionality, and done it better than anything I could do. Use the packages instead of this script:

Description

In its basic usage, this script will modify the router such that blocked addresses are null routed and unreachable. Since the address blocklist is full of advertising, malware, and tracking servers, this setup is generally a good thing. In addition, the router will update the blocklist weekly. However, the blocking is leaky, so do not expect everything to be blocked.

@Belphemur
Belphemur / bridge-conf
Last active January 29, 2024 11:45
Configuration and scripts for OpenVPN in Bridged Mode. Script to generate new client (with their keys and configuration file for OpenVPN). Script to manage the bridge. Configuration for systemd to start/stop the OpenVPN with Brige.
#!/bin/bash
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth="eth0"
eth_ip="192.168.42.2"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.42.255"
eth_gateway="192.168.42.1"
eth_mac="XX:XX:XX:XX:XX:XX"
@codenameone
codenameone / FetchFromPropertyCross.java
Created February 10, 2016 07:08
This is a simple block of code used by some samples in Codename One it fetches housing listings
int pageNumber = 1;
java.util.List<Map<String, Object>> fetchPropertyData(String text) {
try {
ConnectionRequest r = new ConnectionRequest();
r.setPost(false);
r.setUrl("http://api.nestoria.co.uk/api");
r.addArgument("pretty", "0");
r.addArgument("action", "search_listings");
r.addArgument("encoding", "json");
r.addArgument("listing_type", "buy");
@codenameone
codenameone / InfiniteScrollAdapterSample.java
Last active July 8, 2020 09:57
Sample Usage of InfiniteScrollAdapter from Codename One fetches data dynamically from a webservice to scroll down infinitely
public void showForm() {
Form hi = new Form("InfiniteScrollAdapter", new BoxLayout(BoxLayout.Y_AXIS));
Style s = UIManager.getInstance().getComponentStyle("MultiLine1");
FontImage p = FontImage.createMaterial(FontImage.MATERIAL_PORTRAIT, s);
EncodedImage placeholder = EncodedImage.createFromImage(p.scaled(p.getWidth() * 3, p.getHeight() * 3), false);
InfiniteScrollAdapter.createInfiniteScroll(hi.getContentPane(), () -> {
java.util.List<Map<String, Object>> data = fetchPropertyData("Leeds");
MultiButton[] cmps = new MultiButton[data.size()];
@codenameone
codenameone / GenericListCellRendererSample.java
Last active July 8, 2020 09:57
Sample of usage for Codename One's GenericListCellRenderer
public void showForm() {
com.codename1.ui.List list = new com.codename1.ui.List(createGenericListCellRendererModelData());
list.setRenderer(new GenericListCellRenderer(createGenericRendererContainer(), createGenericRendererContainer()));
Form hi = new Form("GenericListCellRenderer", new BorderLayout());
hi.add(BorderLayout.CENTER, list);
hi.show();
}
private Container createGenericRendererContainer() {
@codenameone
codenameone / ListCellRendererSample.java
Last active July 8, 2020 09:57
A trivial sample of the list cell renderer in Codename One
class MyYesNoRenderer extends Label implements ListCellRenderer {
Label label = new Label(" ");
public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
if( ((Boolean)value).booleanValue() ) {
setText("Yes");
} else {
setText("No");
}
return this;
}
@codenameone
codenameone / GRMMModel.java
Created February 10, 2016 20:36
A Codename One ListModel that displays a million GRMM books
class GRMMModel implements ListModel<Map<String,Object>> {
@Override
public Map<String, Object> getItemAt(int index) {
int idx = index % 7;
switch(idx) {
case 0:
return createListEntry("A Game of Thrones " + index, "1996");
case 1:
return createListEntry("A Clash Of Kings " + index, "1998");
case 2:
@codenameone
codenameone / MultiButtonSample.java
Created February 15, 2016 12:27
Sample code for the Codename One MultiButton class
MultiButton twoLinesNoIcon = new MultiButton("MultiButton");
twoLinesNoIcon.setTextLine2("Line 2");
MultiButton oneLineIconEmblem = new MultiButton("Icon + Emblem");
oneLineIconEmblem.setIcon(icon);
oneLineIconEmblem.setEmblem(emblem);
MultiButton twoLinesIconEmblem = new MultiButton("Icon + Emblem");
twoLinesIconEmblem.setIcon(icon);
twoLinesIconEmblem.setEmblem(emblem);
twoLinesIconEmblem.setTextLine2("Line 2");
@codenameone
codenameone / SQLExplorer.java
Created March 2, 2016 13:22
Sample for using SQLite in Codename One using the Database API. This sample presents a UI that allows querying the database and viewing the results in a table
Toolbar.setGlobalToolbar(true);
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_QUERY_BUILDER, s);
Form hi = new Form("SQL Explorer", new BorderLayout());
hi.getToolbar().addCommandToRightBar("", icon, (e) -> {
TextArea query = new TextArea(3, 80);
Command ok = new Command("Execute");
Command cancel = new Command("Cancel");
if(Dialog.show("Query", query, ok, cancel) == ok) {
Database db = null;