Skip to content

Instantly share code, notes, and snippets.

Avatar

Lukasz Piliszczuk lukaspili

View GitHub Profile
@3dd13
3dd13 / ruby_ftp_example.rb
Created Nov 5, 2011
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
View ruby_ftp_example.rb
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@dodyg
dodyg / gist:5823184
Last active Apr 18, 2022
Kotlin Programming Language Cheat Sheet Part 1
View gist:5823184

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@wontondon
wontondon / AssetDatabaseOpenHelper.java
Created Oct 8, 2011
Copy sqlite database from assets dir - Android
View AssetDatabaseOpenHelper.java
package com.javatarts.basketballgm.data;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
@kalmbach
kalmbach / gist:4471560
Created Jan 7, 2013
Rake task sugar for Sequel Migrations (version, migrate, rollback, reset)
View gist:4471560
namespace :db do
require "sequel"
Sequel.extension :migration
DB = Sequel.connect(ENV['DATABASE_URL'])
desc "Prints current schema version"
task :version do
version = if DB.tables.include?(:schema_info)
DB[:schema_info].first[:version]
end || 0
View GlideHelper.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.stream.StreamModelLoader;
View rubber_range_picker.dart
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(ExampleApp());
class ExampleApp extends StatelessWidget {
@override
@abhinavmsra
abhinavmsra / rspec_json_helper.md
Created Jul 11, 2016
DRY JSON Parsing in Rspec Tests
View rspec_json_helper.md
# spec/support/request_helpers.rb
module Requests
  module JsonHelpers
    def json
      JSON.parse(response.body)
    end
  end
end
View overlay_container.dart
import 'package:flutter/material.dart';
class OverlayContainer extends StatefulWidget {
/// The child to render in the regular document flow (defaults to Container())
final Widget child;
/// The widget to render inside the [OverlayEntry].
final Widget overlay;
/// Offset to apply to the [CompositedTransformFollower]
@pyrliu
pyrliu / .gitlab-ci.yml
Last active Mar 23, 2020
graphile-migrate with GitLab CI (community edition) "post-merge-master" validate, commit and push back to master
View .gitlab-ci.yml
stages:
- pre-build
migrate-test:
image: node:12
stage: pre-build
only:
- master
allow_failure: false
before_script:
@singingwolfboy
singingwolfboy / PgTypesLibphonenumberPlugin.ts
Last active Feb 14, 2020
A plugin for Postgraphile that provides support for the "phone_number" type from pg_libphonenumber: https://github.com/blm768/pg-libphonenumber Note that this support requires installing libphonenumber-js on the Postgraphile server: https://github.com/catamphetamine/libphonenumber-js
View PgTypesLibphonenumberPlugin.ts
import { Plugin, Build, ScopeGraphQLScalarType } from "graphile-build";
import { PhoneNumber, parsePhoneNumber } from "libphonenumber-js";
declare module "graphile-build" {
interface ScopeGraphQLScalarType {
isPhoneNumberScalar: boolean;
}
}
export default (function PgTypesLibphonenumberPlugin(builder) {