Skip to content

Instantly share code, notes, and snippets.

@aonurdemir
aonurdemir / page.js
Created March 5, 2020 07:09
Two controller and a service, by Angular
/**
* Two controller and a service, by Angular
*/
var app = angular.module("gcm_user_based_stats",[]);
app.controller("ChartController",['$http','ChartDataService',function($http,ChartDataService){
ChartDataService.on_get_data().then(null, null, function(data) {
//to when notified by the service
});
@aonurdemir
aonurdemir / 2sum.java
Created November 19, 2019 21:49
2sum
class Solution {
public int[] twoSum(int[] nums, int target) {
HashMap<Integer,Integer> hash = new HashMap<Integer,Integer>();
for(int i=0; i < nums.length; i++){
int searched = target - nums[i];
if(hash.containsKey(searched)){
return new int[] {hash.get(searched),i};
@aonurdemir
aonurdemir / 3sum.java
Created November 19, 2019 21:04
3sum
import java.util.Arrays;
class Solution {
public List<List<Integer>> threeSum(int[] nums) {
int sum=0;
List<List<Integer>> ret = new ArrayList<List<Integer>>();
Arrays.sort(nums);
@aonurdemir
aonurdemir / line_renderer.txt
Created October 13, 2019 09:52
Unity line renderer
https://answers.unity.com/questions/422186/remove-points-of-linerenderer.html
public static void ReplaceJsonValue()
{
string filepath = "../../json1.json";
string result = string.Empty;
using (StreamReader r = new StreamReader(filepath))
{
var json = r.ReadToEnd();
var jobj = JObject.Parse(json);
foreach (var item in jobj.Properties()) {
item.Value = item.Value.ToString().Replace("v1", "v2");
@aonurdemir
aonurdemir / mysql.md
Created September 19, 2019 13:37 — forked from jackblack369/mysql.md
[mysql] #mysql
  • the size of blob column
     A BLOB can be 65535 bytes (64 KB) maximum.
     If you need more consider using:
     a MEDIUMBLOB for 16777215 bytes (16 MB)
     a LONGBLOB for 4294967295 bytes (4 GB).
    
  • join sql
  • string convert to timstamp
@aonurdemir
aonurdemir / size.sql
Last active September 4, 2019 11:19
Mysql Table Sizes
https://aws.amazon.com/premiumsupport/knowledge-center/view-storage-rds-mysql-mariadb/
#Run the following query to find the size of each user-created database:
select table_schema, round(sum(data_length+index_length)/1024/1024/1024,2) "size in GB" from information_schema.tables group by 1 order by 2 desc;
#In some cases, MySQL creates internal temporary tables that can't be removed because a query is intervening. These temporary tables aren't part of the table named "tables" inside information_schema. Run the following query to find these internal temporary tables:
select * from innodb_sys_tables where name like '%#%';
cd JAVA-HOME/bin
keytool -genkey -alias <alias> -keyalg RSA -keystore <path/key-store> -storepass <password>
keytool -importkeystore -srckeystore <path/key-store> -destkeystore <path/key-store> -deststoretype pkcs12
@aonurdemir
aonurdemir / get_public_key.sh
Last active December 18, 2019 09:27
Add new pem file to EC2 - ssh - key - generate
Connect to machine you want to give access
$ sudo adduser <onur.demir>
$ sudo su <onur.demir>
make sure your are in user's home directory.
$ cd
Create .ssh directory, and change the directory permission to 700 (only the file owner can read, write or open the directory):
$ mkdir .ssh
$ chmod 700 .ssh
Create an empty file called authorized_keys in the .ssh directory and change its permissions to 600 (only the file owner can read or write to the file)
@aonurdemir
aonurdemir / gist:d9aca000988131597b2772301f722b61
Created July 25, 2019 15:06
elasticsearch update document query
POST /productionusers/_update_by_query
{
"query": {
"bool": {
"filter": [
{
"terms": {
"id": [
108513
]