# jimmy0699

Experience

#### 7,040

• Member Since 1 Year Ago
• 53 Lessons Completed
• 0 Favorites

24th November, 2017

jimmy0699 started a new conversation Algorithm Required Unique Permutation Of Matrix • 10 months ago

Algorithm required, any language, or pseudo language

TLDR: have an array of arrays, you need to sort each inner array in way that matches fallowing requirements:

1. Input array contains set of arrays.
2. Each inner array contains unique elements.
3. Each inner array may have different length and different values.
4. Output array must contain exact same values.
5. Output inner array must have unique values on same key.
6. If there is no solution, wildcard ie.: null are allowed.
7. Wildcards can be duplicated on same key.
8. Solution should have as few wildcards as possible.
9. Algorithm should be able to handle array up to 30x30 in less than 180 s. so avoid bruteforcing.

my best solution so far is to get all elements, define maximum size of array, (so in input array is 2x3 output must be 3x3) then loop trough all elements and fill array with first one and fallow until all elements are used. I have found that key here is order of elements you fill.

Examples

``````[X, Y] solved by [X,Y]
[X, Y] .         [Y,X]

[X, Y, Z] solved by [X,Y,Z]
[X, Y, Z] .         [Z,X,Y]
[X, Y, Z] .         [Y,Z,X]

[X, Y, Z] solved by [X,Y,Z]
[X, A, Z] .         [Z,X,A]
[X, Y, A] .         [Y,A,X]

[X, Y] solved by [X,Y,_]
[X, Y] .         [_,X,Y]
[X, Y] .         [Y,_,X]
``````

This may looks easy but this is not

jimmy0699 left a reply on How To Name Polimorphic Table • 10 months ago

or `user_saw`, or just `seen` cant decide ;(

jimmy0699 started a new conversation How To Name Polimorphic Table • 10 months ago

how to name polimorphic table with info about user have see/read things ? like message, notifcation, article etc...

3rd November, 2017

jimmy0699 left a reply on How To Solve This Riddle? • 11 months ago

ok i think we are close now i have this idea

1. increase size of input array to number of element of highest occurrences or highest length of child depends what is bugger
2. trying to find all placaes for X, then trying to all places for Y and so on.
3. every time when its find add it to array that keeps used elements to prevents duplicates.
``````Route::get('/test', function () {
\$input = [
'A' => ['X', 'Y', 'Z', 'I'],
'B' => ['X', 'Y', 'Z', 'I'],
'C' => ['X', 'Y', 'Z', 'I'],
'D' => ['X', 'Y', 'Z', 'I'],
];

\$output = [];

\$h = getHeight(\$input);

// filling te missing wildcards;
foreach(\$input as \$k => \$v) {
for(\$i=0;\$i<\$h;\$i++) {
if (!isset(\$input[\$k][\$i]))
\$input[\$k][\$i] = '';
}
\$output[\$k] = [];
\$used[\$k] = [];
}

\$j = 0;
foreach(\$input as \$key2 => \$col2) {
foreach(\$col2 as \$k => \$elem) {
//            foreach(\$input as \$key2 => \$col2) {

//                \$i = 0;
//                for(;;) {
foreach(\$input as \$key => \$col) {
for(\$i=0;\$i<\$h;\$i++) {
dump("TRYING: \$key \$i = \$elem");
if (!in_array(\$elem, getRow(\$output, \$i)) && !in_array(\$elem, \$used[\$key]) && (!isset(\$output[\$key][\$i]) || \$output[\$key][\$i] == '')) {

if (in_array(\$elem, \$col)) {
dump("ok");
\$output[\$key][\$i] = \$elem;
\$used[\$key][] = \$elem;
\$j = \$i;
\$i = 0;
break;
}
}
}

}
}
}

foreach(\$output as \$k => \$o) {
ksort(\$output[\$k]);
}

dump(\$output);
});
``````

2nd November, 2017

jimmy0699 left a reply on How To Solve This Riddle? • 11 months ago

i menage to write script for calculating all possibilities, and verify if there are valid or not and returns first valid permutation. if anyone try to go this way its wrong - just saying

for array 5x5 you have 5!^5 permutations witch is 24883200000 turn into gigabites is 23Gb memory allocated with means crash on defining loops itself :(

1st November, 2017

jimmy0699 left a reply on Laravel Passport For API • 11 months ago

I personally use passport in my api projects, its ok, but there is no function to logout, and you will have to make some extra endpoint to pass device_token to make push notofications

jimmy0699 left a reply on How To Solve This Riddle? • 11 months ago

@tisuchi on array B and C you have Y on key 0 i have one solution with is not working perfectly, its ok for simple case

``````function calculate(\$array)
{

\$ii = 0;
foreach (\$array as \$j => \$col) {
if (\$ii == 0) {
\$final[\$j] = \$col;
} else {
\$used = \$unused = [];
\$k = 0;
foreach (\$col as \$i => \$elem) {
foreach (\$col as \$elem2) {
\$row = \$this->getRow(\$final, \$i);
if (!in_array(\$elem2, \$row) && !in_array(\$elem2, \$used)) {
\$used[] = \$elem2;
\$final[\$j][\$k] = \$elem2;
\$k++;
}
//                        \$unused = collect(array_diff(\$col, \$used))->toArray();

}
}
}
\$ii++;
}

return \$final;
}
``````

but i thing this is wrong way

31st October, 2017

jimmy0699 left a reply on How To Solve This Riddle? • 11 months ago

@36864 yes your rules totally match my need :) @tisuchi appreciated, but your function is way to simple to solve this problem,

I have two almost working solution but there is always something that breaks it up :(, i will post it in few hours when i get back from work

jimmy0699 left a reply on How To Solve This Riddle? • 11 months ago

those are ok

``````'A' => ['X', 'Y', ''],
'B' => ['', 'X', 'Y'],
'C' => ['Y', '', 'X'],
``````
``````'A' => ['X', 'Y'],
'B' => ['', 'X', 'Y'],
'C' => ['Y', '', 'X'],
``````

this may be much difficult to compute but technically is ok too

``````'A' => ['X', 'Y'],
'B' => ['Y', 'X'],
'C' => ['', '', 'X', 'Y'],
``````

last one, i belive you mean this:

``````'A' => ['X', 'Y'],
'B' => ['Y', 'X'],
'C' => ['', ''],
``````

is ok steight away, empty string is kinda `joker`

jimmy0699 left a reply on How To Solve This Riddle? • 11 months ago

@36864 elements in inner array can't be moved between arrays and there is no duplicates in single inner array and your input should be solved with this:

``````\$output = [
'A' => ['X', 'Y', ''],
'B' => ['Y', '', 'X'],
'C' => ['', 'X', 'Y'],
];
``````

jimmy0699 left a reply on How To Solve This Riddle? • 11 months ago

@mushood Nope, x,y,z is the easest case, array can by evel like this:

``````    \$input = [
'A' => ['X', 'Y', 'Z'],
'B' => ['X', 'Y', 'Z', 'I', 'J'],
'C' => ['X', 'Y', 'Z', 'I'],
'D' => ['X', 'Y', 'I'],
];

``````

jimmy0699 started a new conversation How To Solve This Riddle? • 11 months ago

Hi, i cant sleep from about a week now, trying to fix this rillde:

have array called input:

``````    \$input = [
'A' => ['X', 'Y', 'Z'],
'B' => ['X', 'Y', 'Z'],
'C' => ['X', 'Y', 'Z'],
];

``````

have to do some magic on it that the output array have unique value on same key on each array, may looks easy bot is not, this magic should add empty string if there is no match for cell, only rule is to have unique value on same key on each inner array

``````    \$output = [
'A' => ['X', 'Y', 'Z],
'B' => ['Z', 'X', 'Y'],
'C' => ['Y', 'Z', 'X],
];
``````

18th May, 2017

jimmy0699 left a reply on Delete Foreign Key With Migrate Reset? • 1 year ago

have you try? :

``````Schema::table('blog_groups', function(Blueprint \$table) { \$table->dropForeign(['item_id']);
});
``````

17th May, 2017

jimmy0699 left a reply on Passport API ? • 1 year ago

flow should loks like this

2. when you have token saving it in session
3. call some route that return view.
4. in this controller before you returning view you call api for data to populate your view and here is place for usage of token
5. api checks token and log you in behide the scenes 6 api returns data 7 web returns view

jimmy0699 left a reply on Passport API ? • 1 year ago

in this example this part is completly useless

``````\$response = \$this->http->request('GET', 'http://localhost/site/', [...

``````

jimmy0699 left a reply on JQuery Question • 1 year ago

have you try ? if you pass it as data in your ajax request sould recivie proper request in your api

jimmy0699 left a reply on JQuery Question • 1 year ago

`\$('form').serialize();` should do the trick

jimmy0699 left a reply on Passport API ? • 1 year ago

then you may do that:

``````public function getAllCategories(Request \$request){

if (!\$request->ajax()) {
\$response = \$this->http->request('GET', 'http://localhost/site/api/categories/all', [
'Accept' => 'application/json',
],
]);

return view(...);
}else{

\$categories = Category::all();

return response()->json(\$categories);
}
}
``````

but this may work but is not recommeded

jimmy0699 left a reply on JQuery Question • 1 year ago

``````console.log(\$( "#plateno" ).val());
``````

then you see output in your browser devtool

jimmy0699 left a reply on JQuery Question • 1 year ago

yes, will return `null` i think

jimmy0699 left a reply on Login Suddenly Returning "These Credentials Do Not Match Our Records." • 1 year ago

my first idea is that you logout function may be incorrect and its not forgeting tokens or related to user data something, if you provide some code may be helpfull

jimmy0699 left a reply on Passport API ? • 1 year ago

#router api.php:

``````Route::group(['prefix' => 'api','middleware' => ['api']], function () {
Route::get('/categories/all', '[email protected]');
}
``````

web.php:

``````Route::get('/categories/all', '[email protected]');
``````

#controllers:

webController:

``````public function getAllCategories(){
\$response = \$this->http->request('GET', 'http://localhost/site/api/categories/all', [
'Accept' => 'application/json',
],
]);

}
``````

apiController:

``````public function getCategories() {
return response()->json(Category::all(), 200)
}
``````

jimmy0699 left a reply on View::share From Service Provider, Error On Migrate? • 1 year ago

you may call View::share in mine Controller constructor or in web middleware, you have db started by then

jimmy0699 left a reply on Passport API ? • 1 year ago

1. yes, totally, that cos you call `'/api/categories'` in function that api/categories pointed to.

2. use

``````return response()->json(\$categories);
``````

jimmy0699 left a reply on Passport API ? • 1 year ago

you have to pass you token in header as Authorization header fallowed by 'Bearer'

like this:

``````        \$response = \$this->get('/api/categories', ['Authorization' => 'Bearer ' . \$token]);
``````

16th May, 2017

jimmy0699 left a reply on LengthAwarePaginator Could Not Be Converted To Int • 1 year ago

``````@foreach (\$processedSales as \$sale)
{{{ var_dump(\$sale) }}}
@endforeach
```
and you see what to use  to populate you table
``````

jimmy0699 left a reply on LengthAwarePaginator Could Not Be Converted To Int • 1 year ago

i dont know much about pagination but this looks weird to me :

``````\$processedSales = (new Sale)->paginate(1);
``````

have you try change it for:

``````\$processedSales = Sale::paginate(1);
``````

jimmy0699 left a reply on Csrf Not Working On Server • 1 year ago

check if you csrf_token is sent inside `<form>` attribute check if your routes are inside `web` middleware check if your `.env` file is correct

jimmy0699 left a reply on Laravel-dompdf: Footer On Every Page Except The Last? • 1 year ago

i had simillar issue, and i had to do this in pdf template using css

jimmy0699 left a reply on Another Way To Set Custom Error Messages Using FormRequest • 1 year ago

i have no idea how to help you but this may be solution for you

``````\$rules = collect(\$request->all())->except(['_token'])->mapWithKeys(function(\$item, \$key) {
return [\$key => 'required'];
})->toArray();

\$this->validate( \$request, \$rules);

``````

or something like this

jimmy0699 left a reply on How To Combine Vue With Laravel • 1 year ago

vue and laravel 5.4 are combined out of the box

``````laravel new app
cd app
npm install
npm run dev
``````

in blade tempates that using vue you should use @{{ vue-var }}

jimmy0699 left a reply on [Laravel 5.4] - Passing Data To Javascript Using Json • 1 year ago

i belive you need to create endpoint that returns json data for your autocomplete function, should looks like this:

``````Route::get('/locations', function() {
return response()->json(Location::all(), 200);
});
``````

and then your function should populate input using ajax something like this:

``````\$('input.autocomplete').autocomplete({
data: function() {
\$.ajax({
url: '/locations',
type: 'get',
success: function(data) {
return data;
},
error: function(data) {
console.log(data);
}
});
},
limit: 20, // The max amount of results that can be shown at once. Default: Infinity.
onAutocomplete: function(val) {
// Callback function when value is autcompleted.
},
minLength: 1, // The minimum length of the input for the autocomplete to start. Default: 1.
});
``````

i dont know that plugin at all just want to show you basic concept

jimmy0699 left a reply on Link To PHP Page • 1 year ago

there is no need to use `/` in url() helper function

jimmy0699 left a reply on Models And Controllers • 1 year ago

take look at polimorphic relations

``````class Category extends Model
{

public function categoryable()
{
return \$this->morphTo();
}
}

``````

and

``````class Product extends Model
{

public function category()
{
return \$this->morphMany('App\Category', 'categoryable');
}
}

``````

and

``````class Post extends Model
{

public function category()
{
return \$this->morphMany('App\Category', 'categoryable');
}
}
``````

11th May, 2017

jimmy0699 left a reply on Storage::delete() Does Not Work In 5.4 • 1 year ago

i think your path should looks like this: /images/34/o8Aq1T3Hi67sOtuTgBh9P7QWA1Ahj4KH2QBR77n0.png

``````Files::where('id', \$id)->get()->first();
``````

you can just simply Files::find(\$id);

``````
same results.

``````

jimmy0699 left a reply on Passing Data Form V-for Loop To Modal Component • 1 year ago

``````<div>
<li v-for="item in items">
<modal :item='item'></modal>
</li>
</div>
``````

of you can pass just a key and take all items from parent controller

like so:

``````<li v-for="(item, key) in items"></li>
``````

9th May, 2017

jimmy0699 left a reply on Casting Types Issue • 1 year ago

silly question that was, `return response()->json()` did the trick

jimmy0699 started a new conversation Casting Types Issue • 1 year ago

Hi, i have model ie. Client and clients table, it has column call nip (varchar)

Model:

``````class Client extends Model
{
protected \$table = 'clients';
protected \$fillable = ['nip'];

protected \$casts = [
'nip' => 'string'
];

public function getNipAttribute(\$v) {
settype(\$v, 'string');
return (string) \$v;
}
...
``````

but that nip is usually sets of digits, how to cast that as string? any thing i done turns into integer in rest client,

6th April, 2017

jimmy0699 left a reply on Wildcard In Route • 1 year ago

``````Route::post('/post/{this}', '[email protected]);
``````

and then

``````public function postingThings(Request \$request, \$thing_to_post) {
return \$this->\$thing_to_post; // sendLetter
}

private function sendLetter() {
\Log::info('hello from sendLetter functions');
return;
}
``````

but i dont know if that works, just guessing

3rd April, 2017

jimmy0699 left a reply on Getting The Same Page In My Comment Section When Going Next • 1 year ago

``````\$('body').on('click', '.pagination a', function(e){
...
var url = \$(this).attr('href');

``````

\$('a.pagination').on('click', function(e){ ... should be some think like

``````var url = \$(this).data('next-page');
``````

for sure, and i would check in browser console in network section what you exactly receive, to make sure u get right response;

28th March, 2017

jimmy0699 left a reply on [Auth] Alphanumeric ID • 1 year ago

try to use Auth::user()->id, Auth::id() looks like to be cast as integer

jimmy0699 left a reply on Notification Not Sending Email • 1 year ago

model that is related to this notification does not

``````use Notifiable;
``````

or does not have email column or email coumn is names is not recognizable;