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
@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-проекта:

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
@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
@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
@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) {
@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 / 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;
@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 / 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 / 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;
}