Skip to content

Instantly share code, notes, and snippets.

//STACK DINAMIS (DENGAN LINKED LIST)
#include <stdio.h>
#include <malloc.h>
#include <string.h>
typedef struct{
char nim[10];
char nama[50];
float nilai;
}nilaiMatKul;
@yusufsyaifudin
yusufsyaifudin / reservestring.java
Created November 26, 2012 14:43
Membalikkan karakter pada sebuah string
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package reversestring;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
@yusufsyaifudin
yusufsyaifudin / facebook_login.php
Last active December 14, 2015 13:58
Facebook login (dari docs facebook)
<?php
$app_id = "YOUR-APP-ID";
$app_secret = "YOUR-APP-SECRET-ID";
$my_url = "YOUR-CALLBACK-URL";
//$my_url = "http://yusyaif.com/facebook";
$code = $_REQUEST["code"];
session_start();
if(empty($code)) {
@yusufsyaifudin
yusufsyaifudin / tugas ai.py
Last active December 17, 2015 23:38
dump code buat Tugas Artificial Intelligence
from Tkinter import *
import Queue
class Application(Frame):
""" A GUI Application"""
def __init__(self, master):
""" Initialize the Frame """
Frame.__init__(self, master)
@yusufsyaifudin
yusufsyaifudin / konverter.pas
Last active August 29, 2015 14:10
just example program that convert celcius to farenheit and vice versa
{* Temperature Converter *}
{* Made by Yusuf Syaifudin *}
{* as request from Muhammad Angga Prasetyo - 2 December 2014 *}
program konverter;
{
Formula to convert celsius to farenheit is:
F = ((9/5)* C) +32
}
@yusufsyaifudin
yusufsyaifudin / distinct_char
Created May 1, 2015 15:57
Return set of unique character from given string
String s = "hksaksaggah";//sample string
String temp2="";//string with no duplicates
HashMap<Integer, Character> tc = new HashMap<>();//create a hashmap to store the char's
char [] charArray = s.toCharArray();
for (Character c : charArray)//for each char
{
if (!tc.containsValue(c))//if the char is not already in the hashmap
{
temp2=temp2+c.toString();//add the char to the output string
tc.put(c.hashCode(),c);//and add the char to the hashmap
package test.tokenizer.tokenizerId;
import java.util.ArrayList;
import yusufs.nlp.tokenizerid.Tokenizer;;
/**
* Hello world!
*
*/
@yusufsyaifudin
yusufsyaifudin / docker-compose-wurstmeister-kafka.yml
Created August 11, 2018 12:33
Docker compose file running kafka in cluster mode
# create topic: /opt/kafka/bin/kafka-topics.sh --create --zookeeper zoo1:2181,zoo2:2181 --topic qmessage --partitions 4 --replication-factor 2
# use official zookeeper image since the wurstmeister/zookeeper image does not currently support zookeeper in replicated mode
# (https://github.com/wurstmeister/kafka-docker/issues/372#issuecomment-409166940)
# for the first run, set the KAFKA_CREATE_TOPICS: 'qmessage:4:2' to create new topic or use the command above.
# For every restart, don't set it, since it will recreate the topic, hence your old data will lost and will make your consumer missing some data.
version: '2'
services:
zoo1:
image: zookeeper:3.4.13
container_name: zoo1
@yusufsyaifudin
yusufsyaifudin / kafka_writer_config.go
Created August 11, 2018 14:04
Create connection into Kafka using Golang
package kafka
import (
"time"
"github.com/segmentio/kafka-go"
"github.com/segmentio/kafka-go/snappy"
)
var writer *kafka.Writer
@yusufsyaifudin
yusufsyaifudin / kafka_reader.go
Created August 11, 2018 14:30
Kafka reader using Golang to use it as Worker
package main
import (
"context"
"fmt"
"os"
"os/signal"
"strings"
"syscall"
"time"