Skip to content

Instantly share code, notes, and snippets.

View ramadani's full-sized avatar
🏠
WFH

Ramadani ramadani

🏠
WFH
View GitHub Profile
@ramadani
ramadani / initialname.js
Last active November 6, 2018 02:04
Create initial name with javascript
function initialName(name, length) {
const parts = name.split(' ');
return parts.filter((it, i) => i <= (length - 1)).map(it => it.substring(0, 1)).join('');
},
@ramadani
ramadani / circle_test.go
Created July 16, 2018 09:42
Full Circle Test Code
package circle
import (
"testing"
)
func TestDiameter(t *testing.T) {
circle := Circle{Radius: 7}
expected := 14.0
@ramadani
ramadani / circle_test.go
Created July 16, 2018 09:30
Snippet from Circle Test Code
package circle
import (
"testing"
)
func TestArea(t *testing.T) {
circle := Circle{Radius: 10}
expected := 314.1592653589793
@ramadani
ramadani / circle.go
Created July 16, 2018 09:29
Circle Package Example with Go
package circle
import (
"math"
)
type Circle struct {
Radius float64
}
public void create(String title, String content) {
String key = mNoteRef.push().getKey();
Note note = new Note(key, title, content);
mNoteRef.child(key).setValue(note);
}
@ramadani
ramadani / NotesPresenter.java
Last active April 9, 2017 03:29
Simple Android App using Firebase Realtime Database - ValueEventListener
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
ArrayList<Note> notes = new ArrayList<Note>();
for (DataSnapshot noteSnapshot: dataSnapshot.getChildren()) {
Note note = noteSnapshot.getValue(Note.class);
notes.add(note);
}
@ramadani
ramadani / Note.java
Last active April 8, 2017 12:59
Simple Android App using Firebase Realtime Database - Java Object
@IgnoreExtraProperties
public class Note {
private String uid;
private String title;
private String content;
public Note() {
}
@ramadani
ramadani / javan_case_study13.java
Created April 7, 2017 09:58
Javan Array Study Case 13
public void case13() {
ArrayList<User> users = new ArrayList<User>();
users.add(new User(1, "Adimas Lutfi Wicaksono"));
users.add(new User(2, "Salman Alfarisi"));
users.add(new User(3, "Muhammad Sholeh"));
ArrayList<User> usersDeleted = new ArrayList<User>();
usersDeleted.add(new User(2, "Salman Alfarisi"));
usersDeleted.add(new User(3, "Muhammad Sholeh"));
@ramadani
ramadani / javan_case_study12.java
Created April 7, 2017 09:14
Javan Array Study Case 12
public void case12() {
ArrayList<User> users = new ArrayList<User>();
users.add(new User(1, "Adimas Lutfi Wicaksono", 1));
users.add(new User(2, "Salman Alfarisi", 1));
users.add(new User(3, "Muhammad Sholeh", 1));
users.add(new User(4, "Yadi Cahyadi", 1));
users.add(new User(5, "Maya Maulani", 2));
}
private class User {
@ramadani
ramadani / javan_case_study14.java
Created April 7, 2017 09:10
Javan Array Study Case 14
public void case14() {
ArrayList<User> users = new ArrayList<User>();
users.add(new User(1, "Adimas Lutfi Wicaksono"));
users.add(new User(2, "Salman Alfarisi"));
users.add(new User(3, "Muhammad Sholeh"));
ArrayList<User> usersNew = new ArrayList<User>();
usersNew.add(new User(4, "Yadi Cahyadi"));
usersNew.add(new User(5, "Maya Maulani"));