Skip to content

Instantly share code, notes, and snippets.

View safaorhan's full-sized avatar
👋
Hey.

Safa Orhan safaorhan

👋
Hey.
View GitHub Profile
@safaorhan
safaorhan / goat.java
Created July 6, 2015 08:59
isUserAGoat()
/**
* Used to determine whether the user making this call is subject to
* teleportations.
*
* <p>As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method can
* now automatically identify goats using advanced goat recognition technology.</p>
*
* @return Returns true if the user making this call is a goat.
*/
public boolean isUserAGoat() {
@safaorhan
safaorhan / QuickBloxHelper.java
Last active August 29, 2015 14:27
QBHelper - Step 1
QBPrivateChatManagerListener privateChatManagerListener;
QBMessageListener<QBPrivateChat> privateChatMessageListener;
public void initFramework() {
//..
privateChatMessageListener = new QBMessageListener<QBPrivateChat>() {
@Override
public void processMessage(QBPrivateChat qbPrivateChat, QBChatMessage qbChatMessage) {
if (qbChatMessage.isMarkable()) {
int opponentId = qbPrivateChat.getParticipant();
@safaorhan
safaorhan / QuickBloxHelper.java
Last active August 29, 2015 14:27
QBHelper - Step 2
public void sendMessageToUser(int opponentId, String message) {
QBPrivateChat privateChat = createPrivateChatIfNotExist(opponentId);
if (null == getDialogOfOpponent(opponentId)) {
retrieveDialogs();
}
sendMessageToChat(privateChat, message);
}
private QBPrivateChat createPrivateChatIfNotExist(int opponentId) {
QBPrivateChat privateChat = privateChatManager.getChat(opponentId);
@safaorhan
safaorhan / QuickBloxHelper.java
Created August 16, 2015 21:06
QBHelper - Step 3
public interface OnChatHistoryLoadedListener {
void onSuccess(ArrayList<QBChatMessage> messages);
void onError(List<String> list);
}
public interface OnUnreadMessageListener {
void onUnreadMessage(int unreadDialogCount);
}
@safaorhan
safaorhan / MediaUtil.java
Created September 1, 2015 08:53
Bitmap - String Conversion
public String encodeThumbnail(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
return Base64.encodeToString(stream.toByteArray(), Base64.DEFAULT);
}
private Bitmap decodeThumbnail(String thumbData) {
byte[] bytes = Base64.decode(thumbData, Base64.DEFAULT);
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
// production.js
var deployd = require('deployd');
var server = deployd({
port: process.env.PORT || 5000,
env: 'development',
db: {
host: 'localhost', // Our mongo instance runs in our server itself. Remember? (127.0.0.1)
port: 27017, // Update this line,
name: 'deployd', // this line,
//Below the class
private int currentIndex = 0;
//On button Click
currentIndex++;
EventItem currentItem = EventAdapter.getItem(currentIndex);
drawItem(currentItem);
@safaorhan
safaorhan / default
Created March 29, 2017 21:41
Deployd API & Vue Admin Panel | Nginx Config
server {
listen 80;
server_name api.my.domain.com;
location / {
proxy_pass http://localhost:3000;
}
}
@safaorhan
safaorhan / Utils.java
Last active October 3, 2022 13:36
Java / Android TC Kimlik No Doğrulama
// Yalnızca UI onayı için kullanılmalıdır
// İş önemi olan durumlarda bu api'yi kullanmalısınız:
// https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?op=TCKimlikNoDogrula
private boolean isTCKNCorrect(String id) {
if (id == null) return false;
if (id.length() != 11) return false;
char[] chars = id.toCharArray();
@safaorhan
safaorhan / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

Let's say alice is a github.com user, with 2 or more private repositories repoN. For this example we'll work with just two repositories named repo1 and repo2

https://github.com/alice/repo1

https://github.com/alice/repo2

You need to be to pull from these repositories without entering a passwords probably on a server, or on multiple servers. You want to perform git pull origin master for example, and you want this to happen without asking for a password.