Potential Git/Rails Disaster: Web page no longer loading - javascript

I have spent a lot of time working on a webpage and have been very lazy about committing things to Git. Today, I attempted to push everything up to my repo, but I think I may have caused a disaster. I am very new to Git and basically just use it for its most basic functions.
I was unable to push anything and the console recommended using a pull request, after doing that and attempting to push again, I began to get a bunch of merge conflicts with my gemfile and gemfile.lock. I tried fixing this issue as well but then I started seeing random <<<<<<HEAD throughout my files (including routes as well as my javascript).
Now when I try to load my localhost page, I seem to have all my content, but my css file will not load resulting in a very ugly page. When I use chrome devtools and try to look at the sources, the application.css.scss is blank, when mine have 1000+ lines of code (and is viewable in the app\assets\stylesheets folder.
Has anyone had something like this happen / know how to remedy the amount of damage I might've done in 15 min. Anything will help as I do not know how to proceed.

you'll want to try doing a git reset --hard to reset your local repo to the state it was at before you ran git pull.
see this answer for reference:
https://stackoverflow.com/a/1223385/3880374
also, in case you're curious about those "random" <<<<<<HEAD strings throughout your files, those are actually added by Git. Per their docs:
Git adds standard conflict-resolution markers to the files that have conflicts, so you can open them manually and resolve those conflicts
Github also has a helpful guide to resolving these conflicts via the command line.

Related

Combine vis-network and vis-timeline on same page

I'm trying to use the network and timeline package on the same page (like I did when using the old 4.21 version, and it works there), but I can't get it to work. It's throwing an error (dataset or array expected), when I provide the vis-datasets to the network. If I remove the load of the js for the timeline in the header, it works - but then I don't have a timeline.
So it looks like loading the package for the timeline is interfering with the vis-datasets definitions.
Any idea what's wrong here?
Just found out that I need to use the DIST from vis-charts to have this working.
Just to clarify this is a known bug we're actively working to solve. It will work as you'd expect eventually. See https://github.com/visjs/vis-network/pull/85 for more information. In the mean time as you found out yourself use vis-charts.

Delete unused files and folders in an existing project

I recently started working on this php project that had some previous developers.
These dev's made a bit of a mess of things, resulting in a huge amount of different files, in PHP as well as javascript files and stylesheets.
I'd like to reduce the amount of files and folders, since they're now over 17k and 5.4k respectively.
Is there a way I could flag unused files for deletion?
Perhaps while navigating the site, e.g. whitelisting files that are being used?
Any help would be greatly appreciated!
I think sometimes its quicker to write things from scratch rather than work with "Megamoth" but if you need to keep it running you probably need to put it into some kind of version control system.
I recommend Git
http://en.wikipedia.org/wiki/Git_%28software%29
https://git-scm.com/
and just start refractoring it.
Version control system will keep your old code so you will be sure that you don't loose anything while deleting or changing your code and you will be able to jump from one version to another very quickly.

Github Windows: Working with 'master' and 'gh-pages' branches

I've got a painfully simple jQuery plugin that I've written and placed on github. I am using Github for Windows and the website itself to manage the project.
Unfortunately, if I try to include any of the .js or .css files that I've uploaded there, through the Raw links, it fails in my browser due to the MIME-type being plain/text.
So, for the last couple of hours I've been researching how to get a copy of the files, through github, that people (including myself) can link to. The first step seems to be creating a project page (gh-pages branch)... that much I have grasped.
However, all of the material I've found so far either expects you to have a UNIX-based system, or do some console-based trickery:
Examples: GitHub, SO, SO
Now, there must be a straightforward way to simply make these source files available for inclusion. I went through the automated steps of creating a 'project page' and now I'm presented with another branch that is claiming to be behind the 'master' branch, but I can't see what I'm supposed to do next. It's not even clear to me why on earth I'm required to make another branch. This whole thing seems far more complicated than it needs to be.
So, to recap:
I've created a branch in Github (using Windows app and website)
I can manage that, and update my files, without incident
I am unable to include the .js and .css files using a 'raw' links
I want to be able to include those files in a page
I'd like to do this through Github for Windows, or on the site itself
If anyone could help walk me through this, I'd appreciate it. Also, I'd expect that A LOT of others would as well.
EDIT: Here is an example of a well-known Github project that has its files available through Github:
Select2:
http://ivaynberg.github.io/select2/select2-3.4.2/select2.js
EDIT2: Okay, conceptually, I now understand why I have to create a separate branch, in order to share the files - as the source control aspects of Github aren't meant to act as a CDN, the project page simply provides a public website where you can place your files. So the question now becomes: How do I put my files from the master branch into the gh-pages branch? I'm not worried about automating it or anything right now, all I want is access to the directory structure so I can place files in there. I've tried syncing and re-syncing my branch with Github Windows, but it tells me that there's nothing to get from the gh-pages branch, even though it's "10 commits behind". What is going on?
EDIT3: Added my own answer, for what I've come up with (so far).
As mentioned, there's lots of information out there for people who are using console-based Git software. However, I could not find a single piece of info on how to do this solely through Github Windows. Well, here is the solution:
Process:
Create a project page, as described here: https://help.github.com/articles/creating-pages-with-the-automatic-generator
Unfortunately, they only have console-based solution for getting a local copy. So here's how the rest of this works in Github Windows... (assumption: project name is myproject, consisting of myproject.js and myproject.css)
After the page has been created (takes a few minutes), open up Github Windows.
In Github Windows, open the repository for the project. On the top menubar it has "in sync", "master", "tools". Click on "master" and switch to "gh-pages" branch - SO example.
When you do this, the folder C:\Users\YourName\Documents\GitHub\myproject will now display the files for the "gh-pages" branch. If you click "master", in Github Windows, it will change the folder structure to once again represent the "master" branch. This is what confused me earlier, you can't see the directory structure for both branches at the same time.
Select the "master" branch in Github Windows.
In Windows Explorer, copy myproject.js and myproject.css into a separate directory (e.g., c:\temp).
Go back to Github Windows and select the "gh-pages" branch.
Go back to Windows Explorer and cut the files you put into c:\temp and paste them into a directory like C:\Users\YourName\Documents\GitHub\myproject\myproject-1.0\
Go back to Github Windows, and you'll see "2 files to be commited". Type in your commit message and click 'Commit'.
Then click 'Sync'.
You can now include these files in your webpages, using a URL like: http://yourname.github.io/myproject/myproject-1.0/myproject.js
Obviously this is a huge pain in the ass to do it this way, if you expect to be updating the source file(s) regularly. So obviously an automated approach would be most ideal. There is an answer for this on SO here, unfortunately it involves UNIX-based scripting which I have zero knowledge of (and, truthfully, no interest in learning just for this). If anyone comes up with a more efficient way of doing this, using only the GUI-based tools, I'm sure myself and many others would be interested in hearing about it.
EDIT: This solution is obviously usurping Github's intended way of doing things, as when I click on the "gh-pages" branch on the github website it tells me that it's "5 commits ahead and 11 commits behind" the master branch, even though they have the same files. So, again, if anyone else has a better GUI-based solution to this problem, I'm all ears.
Git(hub) software for Windows is the buggiest thing I've ever used (well, besides Windows itself). Back when I used Windows, I could hardly get anything to work with Git at all.
But, anyways, to answer your question, if you open a command prompt and type in
git checkout -b gh-pages
(if it complains about branch gh-pages already existing, remove the -b.)
it should switch the branch. Then, you can launch notepad++ or whatever text editor you use (you might have to do it from the terminal, I can't remember), add the file you want, and then type in (in cmd):
git add .
This recursively adds all files in the folder to Git.
git commit -m "Add file for easy user download"
This adds the commit message.
git remote add origin git#github.com:yourusername/yourrepository.git
This adds the Github repo so you can push to it
git push origin gh-pages
This pushes your changes to Github.
And, you're all set!
You might want to read this on Git branching.

Nice Menus drupal module not working in Firefox after after module is moved to /all/modules

i am currently cleaning up a messy drupal site that i will have to administer in the coming months.
My first move was to move all custom modules to /sites/all/modules
In all browsers this causes no issues, except firefox.
The Menus render correctly but do not accept mouse-input ...
When i copy the module back to /modules/ all is fine again.
I checked all the source files for hidden hard-coded references but could not find anything.
Maybe someone can get me started on where to look for solutions next?
Thanks!
You need to rebuild the system table after moving a module to a new directory. The best way to do this is drush rr You'll need to install drush and registry_rebuild modules on your system but it will rapidly rewrite your system table to match the new file structure. You should also be able to rebuild the system table by just visiting the /modules page.

Javascript Wordpress Stopped Working

Can anyone quickly look at this and see why jquery doesn't seem to be working? It was working earlier today, and I'm not sure what I could have touched that would cause it to stop.
I have a jsfiddle set up here: http://jsfiddle.net/Nqdb3/
But if that's not good for troubleshooting this I can provide the actual site.
I couldn't log in, But I can tell you that many times I have encountered jQuery problems in wordpress both in admin and front end.
These usual suspects are plugins but it happened to me in the past without even touching the site.
1) start disabling all plugins one by one - this will eliminate the possibility of different scripts that cause it. If you were lucky, you will discover the culprit.
2) upload the js folder from the same wordpress installation.
-- download the same version you already have
-- upload the js directory under wp-includes - all of it. and replace your current directory .
For me it worked many (many) times.

Categories

Resources