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
@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 / 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 / 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");
@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"
@teffalump
teffalump / README.md
Last active January 4, 2025 13:50
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.

@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