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 / JSONParserSample.java
Created March 3, 2016 11:29
A sample that parses JSON from the ASOIF webservice
Form hi = new Form("JSON Parsing", new BoxLayout(BoxLayout.Y_AXIS));
JSONParser json = new JSONParser();
try(Reader r = new InputStreamReader(Display.getInstance().getResourceAsStream(getClass(), "/anapioficeandfire.json"), "UTF-8")) {
Map<String, Object> data = json.parseJSON(r);
java.util.List<Map<String, Object>> content = (java.util.List<Map<String, Object>>)data.get("root"); // <1>
for(Map<String, Object> obj : content) { // <2>
String url = (String)obj.get("url");
String name = (String)obj.get("name");
java.util.List<String> titles = (java.util.List<String>)obj.get("titles"); // <3>
if(name == null || name.length() == 0) {
@codenameone
codenameone / ListContactsSample.java
Last active July 8, 2020 09:57
Sample listing the contacts entry on the device using the Codename One Contacts API
Form hi = new Form("Contacts", new BoxLayout(BoxLayout.Y_AXIS));
hi.add(new InfiniteProgress());
int size = Display.getInstance().convertToPixels(5, true);
FontImage fi = FontImage.createFixed("" + FontImage.MATERIAL_PERSON, FontImage.getMaterialDesignFont(), 0xff, size, size);
Display.getInstance().scheduleBackgroundTask(() -> {
Contact[] contacts = Display.getInstance().getAllContacts(true, true, false, true, false, false);
Display.getInstance().callSerially(() -> {
hi.removeAll();
for(Contact c : contacts) {
@rcubetrac
rcubetrac / rcabook-setup.sh
Created April 6, 2016 20:55
Roundcube LDAP Setup
#!/bin/bash
#------------configuration--------------------------------
# the url of the openldap server
server="ldap://localhost:389";
# the static config file of openldap
config="/etc/ldap/slapd.conf";
# the LDAP base suffix and admin rootdn
@matburt
matburt / flask_handler.py
Last active October 6, 2023 14:15
Demonstrating a basic flask POST request handler that examines request headers.
#!/usr/bin/env python
from flask import Flask, request, abort, jsonify
app = Flask(__name__)
@app.route('/push', methods=['POST'])
def handle_push():
if not request.json:
abort(400)
if 'AnsibleTower' in request.headers and request.headers['AnsibleTower'] == 'xSecretx':
# Trigger some other external action
set vpn l2tp remote-access authentication mode local
set vpn l2tp remote-access authentication local-users username <username> password <password>
set vpn l2tp remote-access client-ip-pool start 10.0.3.10
set vpn l2tp remote-access client-ip-pool stop 10.0.3.20
set vpn l2tp remote-access dns-servers server-1 10.0.0.1
set vpn l2tp remote-access ipsec-settings authentication mode pre-shared-secret
set vpn l2tp remote-access ipsec-settings authentication pre-shared-secret <secret>
set vpn l2tp remote-access ipsec-settings ike-lifetime 3600
@nav-mike
nav-mike / docker.md
Last active May 3, 2021 07:12
Использование docker compose с rails

Использование docker compose с rails + postgresql

Настройка проекта

Прежде чем начать, убедитесь, что у вас установлен docker и docker-compose, если же нет, то используйте ссылки в конце документа.

Для использования docker в своем проекте, первое, что нужно сделать, это добавить Dockerfile. Этот файл описывает процесс сборки контейнера для вашего проекта. В нем указываются настройки сборки и инструкции для установки зависимостей.

Пример такого файла для простого rails-проекта:

@Qix-
Qix- / sha256.sh
Last active February 15, 2025 07:24
SHA256 in (mostly) pure Bash script
#!/usr/bin/env bash
# Released into the Public Domain.
#
# Original implementation in C by Brad Conte ([email protected]) <https://github.com/B-Con/crypto-algorithms>
# Ported to Bash (lol) by Josh Junon ([email protected]) <https://github.com/qix->
#
# Yes, it's absolutely as slow as it looks.
#
# The only external dependency it has is on a utility called `od`,
@gunnarx
gunnarx / gist:527fbc385a2e76f89609d837b6447f85
Last active December 3, 2024 07:45
Docker to Virtualbox
skeithc@freedom ~ % ethminer --help
Usage ethminer [OPTIONS]
Options:
Work farming mode:
-F,--farm <url> Put into mining farm mode with the work server at URL (default: http://127.0.0.1:8545)
-FF,-FO, --farm-failover, --stratum-failover <url> Failover getwork/stratum URL (default: disabled)
--farm-retries <n> Number of retries until switch to failover (default: 3)
-S, --stratum <host:port> Put into stratum mode with the stratum server at host:port
-SF, --stratum-failover <host:port> Failover stratum server at host:port
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active August 17, 2025 10:12
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).