Skip to content

Instantly share code, notes, and snippets.

View oogatta's full-sized avatar

Naohiro Oogata oogatta

View GitHub Profile
@oogatta
oogatta / 5.txt
Last active October 3, 2017 12:12
// ☁️ Admin node
//   JS だけ value ではソートが効かないのはバグか仕様か
admin.database().ref().child("test").child("Admin")
.orderByChild("fuga") // ソートキー
.on("child_added", snapshot => {
console.log(`(${snapshot.val().hoge}, ${snapshot.val().fuga})`);
});
// 🍎 iOS Swift
@oogatta
oogatta / 4.txt
Last active October 2, 2017 17:13
// ☁️ Admin node
admin.database().ref().child("test").child("Admin")
.orderByKey() // キーでソート
.limitToLast(3) // 切り取る範囲
.once("value", snapshot => {
Object.values(snapshot.val()).forEach(value => {
console.log(`(${value.hoge}, ${value.fuga})`);
});
});
@oogatta
oogatta / 3.txt
Last active October 2, 2017 17:14
// ☁️ Admin node
admin.database().ref().child("test").child("Admin")
  .orderByKey()   // キーでソート
  .limitToFirst(3) // 切り取る範囲
.once("value", snapshot => {
Object.values(snapshot.val()).forEach(value => {
console.log(`(${value.hoge}, ${value.fuga})`);
});
});
@oogatta
oogatta / 2.txt
Last active October 2, 2017 17:14
// ☁️ Admin node
admin.database().ref().child("test").child("Admin")
.orderByKey() // キーでソート
.once("value", snapshot => {
Object.values(snapshot.val()).forEach(value => {
console.log(`(${value.hoge}, ${value.fuga})`);
});
});
// 🍎 iOS Swift
@oogatta
oogatta / 1.txt
Last active October 2, 2017 17:15
// ☁️ Admin node
admin.database().ref().child("test").child("Admin")
.once("value", snapshot => {
Object.values(snapshot.val()).forEach(value => {
console.log(`(${value.hoge}, ${value.fuga})`);
});
});
// 🍎 iOS Swift
Database.database().reference().child("test").child("iOS")
FirebaseDatabase.getInstance().reference.child("test").child("Android").apply {
setValue(null)
push().setValue(mapOf("hoge" to 1, "fuga" to 5))
push().setValue(mapOf("hoge" to 2, "fuga" to 4))
push().setValue(mapOf("hoge" to 3, "fuga" to 3))
push().setValue(mapOf("hoge" to 4, "fuga" to 2))
push().setValue(mapOf("hoge" to 5, "fuga" to 1))
}
let targetReference = Database.database().reference().child("test").child("iOS")
targetReference.setValue(nil)
targetReference.childByAutoId().setValue(["hoge": 1, "fuga": 5])
targetReference.childByAutoId().setValue(["hoge": 2, "fuga": 4])
targetReference.childByAutoId().setValue(["hoge": 3, "fuga": 3])
targetReference.childByAutoId().setValue(["hoge": 4, "fuga": 2])
targetReference.childByAutoId().setValue(["hoge": 5, "fuga": 1])
with (admin.database().ref().child("test").child("Admin")) {
set(null);
push().set({"hoge": 1, "fuga": 5});
push().set({"hoge": 2, "fuga": 4});
push().set({"hoge": 3, "fuga": 3});
push().set({"hoge": 4, "fuga": 2});
push().set({"hoge": 5, "fuga": 1});
}
class MainActivity : AppCompatActivity() {
val controller = MySweetController()
var vmList = arrayListOf<MySweetViewModelable>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
vmList.add(TitleViewModel("Hello, Ebisu!"))
// ...
my_sweet_recycler_view.adapter = controller.adapter
updateController()
class MainActivity : AppCompatActivity() {
lateinit var adapter: RecyclerView.Adapter<RecyclerView.ViewHolder>
var vmList = arrayListOf<MySweetViewModelable>()
override fun onCreate(savedInstanceState: Bundle?) {
// Title
vmList.add(TitleViewModel("Hello, Ebisu!"))
// ...
adapter = MySweetAdapter(vmList)
my_sweet_recycler_view.adapter = adapter
}